dsh-selfupdater 0.4.14 → 0.4.15

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.
Files changed (2) hide show
  1. package/lib/index.js +26 -2
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -296,10 +296,34 @@ export function apply(ctx) {
296
296
  * 返回数据与 DSH 小节同款三行模板:当前版本 / 最新版本 / 上次检查。
297
297
  */
298
298
  const pluginBusy = () => existsSync(pluginLockFile);
299
- /** 读插件状态并合并"服务端视角"的忙闲标记。 */
299
+ /**
300
+ * 读插件状态并合并"服务端视角"的忙闲标记。
301
+ *
302
+ * 【为何要归位 done_pending_restart】更新成功后 setState 把
303
+ * done_pending_restart 写进磁盘,但"是否已经重启"只有通过比较
304
+ * 真实落盘版本才能判定:重启后 resolveInstalledVersion 读到的新版本
305
+ * 已经等于 targetVersion(更新已生效),此时再把"请重启生效"的徽章
306
+ * 继续挂在界面上就是误导(用户实测"重启后还一直显示请重启")。
307
+ * 这里在读取时归一化:若状态是 done_pending_restart 且当前真实
308
+ * 运行版本已 >= targetVersion,说明更新已生效,把 state 归位为 idle,
309
+ * 并顺手覆写磁盘,避免每次读都重复判定。
310
+ */
300
311
  const pluginStatusView = () => {
301
312
  const status = readPluginStatus(dshStateDir);
302
- return { ...status, state: status.state ?? (pluginBusy() ? 'running' : 'idle') };
313
+ const state = status.state ?? (pluginBusy() ? 'running' : 'idle');
314
+ // 仅处理"待重启"终态:targetVersion 存在才可能有归位判定。
315
+ if (state === 'done_pending_restart' && typeof status.targetVersion === 'string' && status.targetVersion !== '') {
316
+ const installedNow = selfInstalled();
317
+ // 重启后真实版本已到目标版本 => 更新已生效,徽章不再有意义。
318
+ // 用 isNewer(target, installed) 判"目标是否还新于已装":返回 false
319
+ // 即目标不再领先,说明已装版本已追平/超过目标(更新已生效)。
320
+ if (installedNow !== null && isNewer(status.targetVersion, installedNow) === false) {
321
+ const settled = { ...status, state: 'idle', message: null };
322
+ writePluginStatus(dshStateDir, settled);
323
+ return settled;
324
+ }
325
+ }
326
+ return { ...status, state };
303
327
  };
304
328
 
305
329
  registerRoute('GET', '/dsh-selfupdater/plugins', (_req, res) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-selfupdater",
3
- "version": "0.4.14",
3
+ "version": "0.4.15",
4
4
  "description": "Self-update plugin for DeepSeek Harness: DSH core upgrades via detached swap script; plugin self-update installs in-place without killing the host and prompts for restart. DSH 主程序与已装插件的一站式在线更新插件。",
5
5
  "license": "MIT",
6
6
  "type": "module",