dsh-config-sync-plugin 0.3.96 → 0.3.97
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/README.en.md +9 -0
- package/README.md +9 -0
- package/index.js +33 -0
- package/package.json +1 -1
- package/tools/selftest.mjs +17 -0
package/README.en.md
CHANGED
|
@@ -257,6 +257,14 @@ Two display fixes on top of 0.3.77:
|
|
|
257
257
|
|
|
258
258
|
The "Plugin update" card now shows an **npm download URL** line with the actual fallback addresses (domestic mirror `registry.npmmirror.com` + official `registry.npmjs.org`). When the GitHub release download is unreachable (common in mainland China), the update package automatically falls back to npm. It is still verified against the authoritative sha256 in `version.json` — switching source never relaxes verification. The two sources back each other up: the mirror can briefly 404 during its first-sync window, and the official source takes over. The npm tarball is byte-identical to the GitHub release tgz (same sha256).
|
|
259
259
|
|
|
260
|
+
### Clicking × with pending changes now actively exits DSH and syncs immediately (0.3.97)
|
|
261
|
+
|
|
262
|
+
In 0.3.96 the beacon could "check once on × and queue the watcher", but the watcher then sat in `wait`, **passively waiting for all DSH processes to disappear** before working. In practice clicking × leaves 7 orphaned processes (the plugin itself runs in one of them, the host child), so the normal close path often fails to clean up and the watcher just idles until its 30-minute timeout — appearing as "queued but nothing happens". This version closes the last gap:
|
|
263
|
+
|
|
264
|
+
1. **Active force-exit**: once `triggerAutoSyncOnClose` returns `queued:true` (there really are pending pull/push), `handleAutoExit` immediately calls `forceCloseDshDetached` — from an **independent detached process** it runs `taskkill /IM "DeepSeek Harness.exe" /F` to kill the whole process family (with a `ping -n 3` ~2s grace period for the normal close to flush state first). This must run in a separate process: force-killing takes down the plugin itself (host child), so no `setTimeout` inside the plugin process would survive long enough to fire.
|
|
265
|
+
2. **Only when something is actually pending**: guarded by `if (result && result.queued)` — clicking × with nothing to sync won't kill DSH; with pending changes, exit + pull/push happen in one shot.
|
|
266
|
+
3. **Regression guards**: selftest asserts the detached force-kill, `/IM /F`, the call after queuing, and the queued guard.
|
|
267
|
+
|
|
260
268
|
### Page-unload beacon replaces the Electron close hook, finally fixing "× does not trigger" (0.3.96)
|
|
261
269
|
|
|
262
270
|
After 0.3.95 fixed the BOM (watcher no longer crashes on launch), the real culprit behind "closing × still does not trigger" surfaced: **the Electron close hook never got installed**. Two ironclad facts — the plugin actually runs in the host child process (`dsh-desktop-host`, a `--expose-internals` node process), so `require('electron')` has no `app`, `electronApp()` returns null and `installQuitWhenAllWindowsClosed` bails at `if (!el) return`; and even if it had `el`, `browser-window-created` fired long before plugin `apply`, so that event never fires again and the `closed` callback never runs. So the "check once on ×" chain added in 0.3.93 **never actually ran** (no new watcher in launch.log, zero hook logs). This version changes tack completely:
|
|
@@ -737,6 +745,7 @@ The log shows which path ran: `文件比较(快筛):比对 N 个,深哈
|
|
|
737
745
|
|
|
738
746
|
| Date | Version | Summary |
|
|
739
747
|
|---|---|---|
|
|
748
|
+
| 2026-11-25 | 0.3.97 | Clicking × with pending pull/push actively force-kills the DSH process family from a detached process (detached taskkill /F); the watcher runs immediately instead of waiting for orphaned processes |
|
|
740
749
|
| 2026-11-24 | 0.3.96 | Page-unload beacon (pagehide→sendBeacon /auto-exit) replaces the dead Electron close hook; fast check (local tracking ref, no fetch) queues the watcher in milliseconds, finally fixing "× does not trigger" |
|
|
741
750
|
| 2026-11-24 | 0.3.95 | Fix post-exit.ps1 losing UTF-8 BOM (PS5.1 decoded as GBK, 55 syntax errors, crashed on launch): restored BOM on all three executors, selftest adds full ps1 BOM assertion to prevent regression |
|
|
742
751
|
| 2026-11-24 | 0.3.94 | Fix cross-restart stale watchers holding the lock: lock records watchPid, reuse checks staleness, stale locks are killed and re-queued; post-exit wait self-clears stale watchers; fixes "switches on, clicking × still triggers nothing" |
|
package/README.md
CHANGED
|
@@ -277,6 +277,14 @@ pwsh -File runtime\sync.ps1 pull `
|
|
|
277
277
|
|
|
278
278
|
「插件更新」卡新增一行 **npm 下载路径**,直接显示实际兜底地址(国内镜像 `registry.npmmirror.com` + 官方 `registry.npmjs.org` 两个源)。GitHub release 整段不通时(国内常见),更新包会自动兜底从 npm 下载;仍按 `version.json` 里的权威 sha256 校验,换源不放宽校验。两个源互为备份:镜像首发同步窗口期会短暂 404,官方源随即兜上。实测 npm tarball 与 GitHub release tgz 是同一份产物、sha256 完全一致。
|
|
279
279
|
|
|
280
|
+
### 点 × 检测到待同步就主动退出 DSH 并立即执行(0.3.97)
|
|
281
|
+
|
|
282
|
+
0.3.96 的信标已经能「点 × 判一次并排好 watcher」,但 watcher 进入 `wait` 后是**被动等 DSH 进程全部消失**才开工。实测点 × 后 DSH 常残留 7 个进程(插件就跑在其中的 host 子进程里),单靠正常关闭流程经常关不干净,watcher 只能干等到 30 分钟超时——表现为「排了队但迟迟不动」。这次补上最后一环:
|
|
283
|
+
|
|
284
|
+
1. **主动强制退出**:`handleAutoExit` 一旦 `triggerAutoSyncOnClose` 返回 `queued:true`(确实有待拉取/待推送),立即调 `forceCloseDshDetached`——从**独立 detached 进程**用 `taskkill /IM "DeepSeek Harness.exe" /F` 整族强杀(中间用 `ping -n 3` 留 2 秒给正常关闭落盘)。必须在独立进程里做:强杀会把插件自己(host 子进程)也带走,任何挂在插件进程内的 `setTimeout` 都来不及执行。
|
|
285
|
+
2. **只在真有待同步时才退出**:`if (result && result.queued)` 守卫——没待同步就点 × 不会误杀 DSH;有待同步才「退出 + 拉取/推送」一气呵成。
|
|
286
|
+
3. **防回归**:selftest 断言 detached 强杀、`/IM /F`、排队后调用与 queued 守卫。
|
|
287
|
+
|
|
280
288
|
### 页面卸载信标取代 Electron 关窗钩子,真正修好「点 × 不触发」(0.3.96)
|
|
281
289
|
|
|
282
290
|
0.3.95 修好 BOM(watcher 不再启动即崩)后,「点 × 还是不触发」的真凶才浮出水面:**Electron 关窗钩子根本没装成功**。两条铁证——插件实际跑在 host 子进程(`dsh-desktop-host`,`--expose-internals` 的 node 进程),`require('electron')` 拿不到 `app`,`electronApp()` 返回 null,`installQuitWhenAllWindowsClosed` 一进来 `if (!el) return` 直接退出;并且就算拿得到,`browser-window-created` 在插件 `apply` 时窗口早已建好,那个事件再也不会触发,`closed` 回调永不执行。所以从 0.3.93 加的「点 × 判一次」这条链**从未真正跑过**(launch.log 无新 watcher、钩子日志 0 命中)。这次彻底换路:
|
|
@@ -719,6 +727,7 @@ pwsh -File sync.ps1 push -ScanHistory
|
|
|
719
727
|
|
|
720
728
|
| 日期 | 版本 | 要点 |
|
|
721
729
|
|---|---|---|
|
|
730
|
+
| 2026-11-25 | 0.3.97 | 点 × 检测到待拉取/待推送后,从独立进程主动强制退出 DSH 进程族(detached taskkill /F),watcher 立刻执行,不再干等残留进程 |
|
|
722
731
|
| 2026-11-24 | 0.3.96 | 页面卸载信标(pagehide→sendBeacon /auto-exit)取代失效的 Electron 关窗钩子,fast 判据(本地 tracking ref、不 fetch)毫秒级排队 watcher,真正修好「点 × 不触发」 |
|
|
723
732
|
| 2026-11-24 | 0.3.95 | 修复 post-exit.ps1 丢 UTF-8 BOM 致 PS5.1 按 GBK 解码、55 处语法错启动即崩:三处执行体补回 BOM,selftest 加全量 ps1 BOM 断言防回归 |
|
|
724
733
|
| 2026-11-24 | 0.3.94 | 修复跨重启僵死 watcher 占锁:锁记 watchPid、复用前查僵死、旧锁杀掉重排;post-exit wait 段过期 watcher 自清让位;解决「勾了开关点 × 仍不触发」 |
|
package/index.js
CHANGED
|
@@ -1769,6 +1769,35 @@ function closeDsh() {
|
|
|
1769
1769
|
return true
|
|
1770
1770
|
}
|
|
1771
1771
|
|
|
1772
|
+
/**
|
|
1773
|
+
* 0.3.97:页面卸载信标检测到「待拉取/待推送」后,主动、强制退出 DSH 进程族,
|
|
1774
|
+
* 让刚排好的 watcher 立刻从 wait 进入 run,而不是干等用户把 DSH 关干净(实测常残留 7 个进程,
|
|
1775
|
+
* 之前只能等 post-exit 的 30 分钟超时)。
|
|
1776
|
+
*
|
|
1777
|
+
* 决定性约束:必须在 detached 的独立进程里做延迟强杀 —— 插件就跑在 DSH 的 host 子进程里,
|
|
1778
|
+
* 强杀会把插件自己也带走,任何挂在插件进程内的 setTimeout 都来不及执行。
|
|
1779
|
+
* 用 cmd /c + ping 做秒级延时(timeout.exe 在无控制台的非交互进程里会报错),
|
|
1780
|
+
* 先给点 × 触发的正常关闭流程一点时间落盘,再 /F 兜底残留进程。
|
|
1781
|
+
*/
|
|
1782
|
+
function forceCloseDshDetached(config) {
|
|
1783
|
+
const dshHome = config?.dshHome || process.env.DSH_HOME || join(homedir(), '.dsh')
|
|
1784
|
+
const sys = process.env.SystemRoot || 'C:\\Windows'
|
|
1785
|
+
const cmd = join(sys, 'System32', 'cmd.exe')
|
|
1786
|
+
const taskkill = join(sys, 'System32', 'taskkill.exe')
|
|
1787
|
+
const imageName = 'DeepSeek Harness.exe'
|
|
1788
|
+
// ping -n 3 ≈ 2s:给正常关闭 + watcher 读锁的余量,之后 /F 强杀残留进程族
|
|
1789
|
+
const script = `ping -n 3 127.0.0.1 >nul & "${taskkill}" /IM "${imageName}" /F`
|
|
1790
|
+
try {
|
|
1791
|
+
const child = spawn(cmd, ['/c', script], { stdio: 'ignore', windowsHide: true, detached: true })
|
|
1792
|
+
try { child.unref?.() } catch { }
|
|
1793
|
+
logLaunch(dshHome, `auto-exit:已排队同步,触发强制退出 DSH 进程族(${imageName} /F,独立进程延迟强杀)`)
|
|
1794
|
+
return true
|
|
1795
|
+
} catch (error) {
|
|
1796
|
+
logLaunch(dshHome, `auto-exit:触发退出失败:${(error && error.message) || error}`)
|
|
1797
|
+
return false
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1800
|
+
|
|
1772
1801
|
function isProcessAlive(pid) {
|
|
1773
1802
|
if (!pid) return false
|
|
1774
1803
|
try { process.kill(pid, 0); return true } catch { return false }
|
|
@@ -3655,6 +3684,10 @@ async function handleAutoExit(req, res, config) {
|
|
|
3655
3684
|
// sendBeacon 的 body 可能是空 / text/plain / application/json,读不读都不影响排队;容错读一下即可。
|
|
3656
3685
|
try { await readBody(req) } catch { }
|
|
3657
3686
|
const result = await triggerAutoSyncOnClose(config, { fast: true })
|
|
3687
|
+
// 0.3.97:检测到待拉取/待推送并排好 watcher 后,主动强制退出 DSH 进程族,
|
|
3688
|
+
// watcher 立刻从 wait 进入 run;不再干等用户关干净(残留进程会让同步卡到 30 分钟超时)。
|
|
3689
|
+
// 必须在独立进程里做——强杀会带走插件自己(插件跑在 DSH 的 host 子进程)。
|
|
3690
|
+
if (result && result.queued) forceCloseDshDetached(config)
|
|
3658
3691
|
sendJson(res, 200, { ok: true, ...result })
|
|
3659
3692
|
} catch (error) {
|
|
3660
3693
|
logLaunch(config?.dshHome || process.env.DSH_HOME || join(homedir(), '.dsh'),
|
package/package.json
CHANGED
package/tools/selftest.mjs
CHANGED
|
@@ -1887,5 +1887,22 @@ console.log('== 0.3.96:页面卸载信标(sendBeacon)绕开 Electron 关
|
|
|
1887
1887
|
/var offBeacon = installExitBeacon\(\)/.test(cliSrc)
|
|
1888
1888
|
&& /ctx\.effect\(function \(\) \{ return function \(\) \{ try \{ offBeacon\(\) \}/.test(cliSrc), 'client.js apply 安装')
|
|
1889
1889
|
}
|
|
1890
|
+
console.log('')
|
|
1891
|
+
console.log('== 0.3.97:检测到待拉取/待推送就主动强制退出 DSH,watcher 立刻执行 ==')
|
|
1892
|
+
{
|
|
1893
|
+
const idxSrc = existsSync(join(pluginRootSelf, 'index.js')) ? readFileSync(join(pluginRootSelf, 'index.js'), 'utf8') : ''
|
|
1894
|
+
check('新增 forceCloseDshDetached 独立进程强制退出函数',
|
|
1895
|
+
/function forceCloseDshDetached\(config\)/.test(idxSrc), 'index.js forceCloseDshDetached')
|
|
1896
|
+
check('强制退出用 detached + unref 独立进程(强杀不会带走插件自己)',
|
|
1897
|
+
/spawn\(cmd, \['\/c', script\][\s\S]{0,120}?detached: true/.test(idxSrc)
|
|
1898
|
+
&& /child\.unref\?\.\(\)/.test(idxSrc), 'index.js detached 强杀')
|
|
1899
|
+
check('taskkill /IM /F 整族强杀 DeepSeek Harness',
|
|
1900
|
+
/taskkill[\s\S]{0,80}?\/IM[\s\S]{0,80}?\/F/.test(idxSrc)
|
|
1901
|
+
|| /"\/IM"[\s\S]{0,120}?"\/F"/.test(idxSrc), 'index.js taskkill /F')
|
|
1902
|
+
check('auto-exit 排队成功后调用 forceCloseDshDetached',
|
|
1903
|
+
/if \(result && result\.queued\) forceCloseDshDetached\(config\)/.test(idxSrc), 'index.js 排队后主动退出')
|
|
1904
|
+
check('只在 queued 时才强制退出(无待同步不误杀 DSH)',
|
|
1905
|
+
/result && result\.queued[\s\S]{0,60}?forceCloseDshDetached/.test(idxSrc), 'index.js queued 守卫')
|
|
1906
|
+
}
|
|
1890
1907
|
process.exit(failures === 0 ? 0 : 1)
|
|
1891
1908
|
|