dsh-dpharness 0.6.0 → 0.6.1
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/lib/changelog.js +10 -0
- package/lib/client.js +90 -13
- package/lib/index.js +15 -1
- package/package.json +1 -1
package/lib/changelog.js
CHANGED
|
@@ -37,6 +37,16 @@ export function npmLatestUrl(pkg) {
|
|
|
37
37
|
* (用户要看的是行为变化,不是我们的 commit 分类)。
|
|
38
38
|
*/
|
|
39
39
|
export const CHANGELOG = [
|
|
40
|
+
{
|
|
41
|
+
version: "0.6.1",
|
|
42
|
+
date: "2026-10-17",
|
|
43
|
+
title: "重启横幅能认出「已经重启过」",
|
|
44
|
+
items: [
|
|
45
|
+
"修复「待重启」横幅在重启后仍然一直提示的问题:真的重启过一次,横幅会自动改口「已生效」,不必再手动点「知道了」。",
|
|
46
|
+
"「是否已生效」改由本机 dsh 的启动轮次判定(每次启动都不同)——「又装了另一个插件」不会再让上一次的重启结论失效。",
|
|
47
|
+
"未生效时会自动复查(最长约 4 分钟),页面不需要手动刷新;连续查不到状态时如实提示「查不到重启状态」,不再让人误以为自己没重启成功。",
|
|
48
|
+
],
|
|
49
|
+
},
|
|
40
50
|
{
|
|
41
51
|
version: "0.6.0",
|
|
42
52
|
date: "2026-10-16",
|
package/lib/client.js
CHANGED
|
@@ -432,6 +432,7 @@ window.__ModuleLoader__.load({
|
|
|
432
432
|
"install.effective": "已生效",
|
|
433
433
|
"install.effectiveBody": "{n}:改动已生效",
|
|
434
434
|
"install.dismiss": "知道了",
|
|
435
|
+
"install.unknownState": "查不到重启状态,可刷新页面确认",
|
|
435
436
|
"install.restartFailed": "重启接口不可用,请手动重启 dsh",
|
|
436
437
|
"install.failed": "安装失败",
|
|
437
438
|
"install.busy": "已有安装任务在进行",
|
|
@@ -677,6 +678,7 @@ window.__ModuleLoader__.load({
|
|
|
677
678
|
"install.effective": "Active",
|
|
678
679
|
"install.effectiveBody": "{n}: changes are live",
|
|
679
680
|
"install.dismiss": "Got it",
|
|
681
|
+
"install.unknownState": "Can't confirm the restart state — reload the page",
|
|
680
682
|
"install.restartFailed": "Restart endpoint unavailable — restart dsh manually",
|
|
681
683
|
"install.failed": "Install failed",
|
|
682
684
|
"install.busy": "Another install is already running",
|
|
@@ -1074,7 +1076,12 @@ window.__ModuleLoader__.load({
|
|
|
1074
1076
|
rememberPending({ pkg: basePackage(target), via: via, at: Date.now() });
|
|
1075
1077
|
/* 本地通道改的是 profile,必须重启才生效 —— 记一条待重启横幅(市场通道热挂载,
|
|
1076
1078
|
不需要;same/none 版本没动,也没什么可生效的)。 */
|
|
1077
|
-
if (!done.market && done.changed)
|
|
1079
|
+
if (!done.market && done.changed) {
|
|
1080
|
+
/* 先钉住宿主这一轮的 bootId(一次本地 GET,拿不到也只是留空)——
|
|
1081
|
+
待重启记录必须记下「安装发生在哪一次启动里」,否则重启后无从判定。 */
|
|
1082
|
+
await primeHostBoot();
|
|
1083
|
+
markRestartPending(item.nameZh || item.name || target);
|
|
1084
|
+
}
|
|
1078
1085
|
return { ok: true, market: Boolean(done.market), via: via, why: "", changed: done.changed };
|
|
1079
1086
|
}
|
|
1080
1087
|
track("plugin_hub", {
|
|
@@ -1132,6 +1139,7 @@ window.__ModuleLoader__.load({
|
|
|
1132
1139
|
loadUpdates(true);
|
|
1133
1140
|
if (done.ok && done.changed) {
|
|
1134
1141
|
track("plugin_hub", { action: "remove_ok" });
|
|
1142
|
+
await primeHostBoot();
|
|
1135
1143
|
markRestartPending(item.nameZh || item.name || target);
|
|
1136
1144
|
} else if (done.ok) {
|
|
1137
1145
|
/* 退出码 0 但磁盘上没变 —— 与安装的 same 同一类三态,别谎报"已卸载" */
|
|
@@ -1398,13 +1406,38 @@ window.__ModuleLoader__.load({
|
|
|
1398
1406
|
所以这条提醒挂在面板与页签顶部,跨视图、跨会话存在,直到重启生效或
|
|
1399
1407
|
用户明确说「知道了」。 */
|
|
1400
1408
|
const RESTART_KEY = "dph-hub-restart-pending";
|
|
1409
|
+
/* 宿主 bootId 缓存 —— 安装时随待重启记录一起落盘,重启后 bootId 变了才是
|
|
1410
|
+
「已生效」的硬证据。时间戳只是兜底:它会被「又装了一个」刷新,也怕时钟回拨。 */
|
|
1411
|
+
let hostBootId = "";
|
|
1412
|
+
let bootInFlight = null;
|
|
1413
|
+
function primeHostBoot() {
|
|
1414
|
+
if (hostBootId) return Promise.resolve(hostBootId);
|
|
1415
|
+
if (bootInFlight) return bootInFlight;
|
|
1416
|
+
bootInFlight = getJson("/api/dpharness/meta")
|
|
1417
|
+
.then((result) => {
|
|
1418
|
+
const body = result && result.data;
|
|
1419
|
+
if (body && typeof body.bootId === "string" && body.bootId) hostBootId = body.bootId;
|
|
1420
|
+
return hostBootId;
|
|
1421
|
+
})
|
|
1422
|
+
.catch(() => hostBootId)
|
|
1423
|
+
.then((value) => {
|
|
1424
|
+
bootInFlight = null;
|
|
1425
|
+
return value;
|
|
1426
|
+
});
|
|
1427
|
+
return bootInFlight;
|
|
1428
|
+
}
|
|
1401
1429
|
function readRestartPending() {
|
|
1402
1430
|
try {
|
|
1403
1431
|
const raw = localStorage.getItem(RESTART_KEY);
|
|
1404
1432
|
if (!raw) return null;
|
|
1405
1433
|
const parsed = JSON.parse(raw);
|
|
1406
1434
|
if (!parsed || !Array.isArray(parsed.names) || !parsed.names.length) return null;
|
|
1407
|
-
return {
|
|
1435
|
+
return {
|
|
1436
|
+
names: parsed.names.map((name) => String(name)).filter(Boolean),
|
|
1437
|
+
at: Number(parsed.at) || 0,
|
|
1438
|
+
/* 旧记录没有 boot 字段 ⇒ 空串 ⇒ 判定回退到时间戳比较 */
|
|
1439
|
+
boot: typeof parsed.boot === "string" ? parsed.boot : "",
|
|
1440
|
+
};
|
|
1408
1441
|
} catch (error) {
|
|
1409
1442
|
return null;
|
|
1410
1443
|
}
|
|
@@ -1427,7 +1460,14 @@ window.__ModuleLoader__.load({
|
|
|
1427
1460
|
const label = String(name || "").trim();
|
|
1428
1461
|
if (!label) return;
|
|
1429
1462
|
const current = hub.restartPending || { names: [], at: 0 };
|
|
1430
|
-
const next = {
|
|
1463
|
+
const next = {
|
|
1464
|
+
names: Array.from(new Set(current.names.concat([label]))),
|
|
1465
|
+
at: Date.now(),
|
|
1466
|
+
/* boot = 装完这一刻宿主是哪一次启动(拿不到就留空,判定回退时间戳)。
|
|
1467
|
+
注意连装多个时 at 会被刷新,boot 不变 —— 正是「最后一次安装之后
|
|
1468
|
+
有没有重启过」这个语义。 */
|
|
1469
|
+
boot: hostBootId || "",
|
|
1470
|
+
};
|
|
1431
1471
|
storeRestartPending(next);
|
|
1432
1472
|
setHub({ restartPending: next });
|
|
1433
1473
|
}
|
|
@@ -2809,9 +2849,10 @@ window.__ModuleLoader__.load({
|
|
|
2809
2849
|
* 实测没有 dshmarket,安装全走本地通道、必须重启)。所以它挂在面板与页签
|
|
2810
2850
|
* 顶部,跨视图、跨会话存在,直到重启生效或用户明确说「知道了」。
|
|
2811
2851
|
*
|
|
2812
|
-
* 挂载时向宿主要 startedAt(/api/dpharness/meta
|
|
2813
|
-
*
|
|
2814
|
-
*
|
|
2852
|
+
* 挂载时向宿主要 startedAt / bootId(/api/dpharness/meta):bootId 变了(老宿主
|
|
2853
|
+
* 只给 startedAt,则看它是否比 pending.at 新)就说明重启已经发生过 —— 这时该说
|
|
2854
|
+
* 「已生效」而不是继续催重启。取不到就按「还没重启」处理:宁可多提醒一次,
|
|
2855
|
+
* 也不能把提醒悄悄吞掉。
|
|
2815
2856
|
*/
|
|
2816
2857
|
function RestartBanner(props) {
|
|
2817
2858
|
const pending = useHub().restartPending;
|
|
@@ -2820,18 +2861,53 @@ window.__ModuleLoader__.load({
|
|
|
2820
2861
|
const [restarting, setRestarting] = react.useState(false);
|
|
2821
2862
|
const [failed, setFailed] = react.useState(false);
|
|
2822
2863
|
const [effective, setEffective] = react.useState(false);
|
|
2864
|
+
const [unknown, setUnknown] = react.useState(false);
|
|
2823
2865
|
react.useEffect(() => {
|
|
2824
2866
|
if (!pending) return undefined;
|
|
2825
2867
|
let alive = true;
|
|
2868
|
+
let timer = 0;
|
|
2869
|
+
let asks = 0;
|
|
2870
|
+
let misses = 0;
|
|
2871
|
+
/* 只问一次是不够的:desktop 的「重启」换的是**宿主进程**,页面往往只是重连
|
|
2872
|
+
而不重新挂载 —— 那一次判定会被永久跳过,横幅就永远停在「待重启」
|
|
2873
|
+
(2026-10-17 用户实测:确实重启过,提示照旧)。所以按退避重试。 */
|
|
2874
|
+
const RETRY_MS = [0, 8000, 20000, 40000];
|
|
2875
|
+
const MAX_ASKS = 10;
|
|
2826
2876
|
/* 先按「需要重启」算:新的待重启(又装了一个)不能沿用上一次的「已生效」 */
|
|
2827
2877
|
setEffective(false);
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
}
|
|
2833
|
-
|
|
2834
|
-
|
|
2878
|
+
setUnknown(false);
|
|
2879
|
+
const ask = async () => {
|
|
2880
|
+
const result = await getJson("/api/dpharness/meta");
|
|
2881
|
+
if (!alive) return;
|
|
2882
|
+
/* ⚠️ getJson 返回的是 { status, data },不是裸 body。这里曾经直接读
|
|
2883
|
+
`body.startedAt`(永远 undefined),「已生效」分支因此从未生效过。 */
|
|
2884
|
+
const body = result && result.data;
|
|
2885
|
+
if (!body || typeof body.startedAt !== "number") {
|
|
2886
|
+
misses += 1;
|
|
2887
|
+
/* 连续取不到就别再假装「需要重启」—— 三次之后改说「确认不了」,
|
|
2888
|
+
否则用户会以为自己没重启成功,反复重启。 */
|
|
2889
|
+
if (misses >= 3) setUnknown(true);
|
|
2890
|
+
} else {
|
|
2891
|
+
misses = 0;
|
|
2892
|
+
setUnknown(false);
|
|
2893
|
+
/* bootId 优先:它每次进程启动都变,不受时钟与「又装一个把 at 刷新」
|
|
2894
|
+
的影响;任一端缺失才回退到时间戳比较。 */
|
|
2895
|
+
const restarted = pending.boot && typeof body.bootId === "string" && body.bootId
|
|
2896
|
+
? body.bootId !== pending.boot
|
|
2897
|
+
: body.startedAt > pending.at;
|
|
2898
|
+
if (restarted) {
|
|
2899
|
+
setEffective(true);
|
|
2900
|
+
return;
|
|
2901
|
+
}
|
|
2902
|
+
}
|
|
2903
|
+
asks += 1;
|
|
2904
|
+
if (asks < MAX_ASKS) {
|
|
2905
|
+
const delay = asks < RETRY_MS.length ? RETRY_MS[asks] : 30000;
|
|
2906
|
+
timer = setTimeout(ask, delay);
|
|
2907
|
+
}
|
|
2908
|
+
};
|
|
2909
|
+
ask();
|
|
2910
|
+
return () => { alive = false; if (timer) clearTimeout(timer); };
|
|
2835
2911
|
}, [pending]);
|
|
2836
2912
|
if (!pending) return null;
|
|
2837
2913
|
const names = pending.names;
|
|
@@ -2857,6 +2933,7 @@ window.__ModuleLoader__.load({
|
|
|
2857
2933
|
h("span", { className: "dph_restartText", key: "text" }, format(t("install.pendingBody"), { n: label })),
|
|
2858
2934
|
h("span", { className: "dph_logCmd", key: "cmds" }, [
|
|
2859
2935
|
armed ? h("span", { className: "dph_setHint", key: "warn" }, t("updates.restartConfirm")) : null,
|
|
2936
|
+
unknown ? h("span", { className: "dph_setHint", key: "unknown" }, t("install.unknownState")) : null,
|
|
2860
2937
|
h("button", {
|
|
2861
2938
|
className: "dph_btn dph_btnPrimary",
|
|
2862
2939
|
key: "restart",
|
package/lib/index.js
CHANGED
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
*/
|
|
36
36
|
|
|
37
37
|
import { spawn } from "node:child_process";
|
|
38
|
+
import { randomUUID } from "node:crypto";
|
|
38
39
|
import fs from "node:fs";
|
|
39
40
|
import os from "node:os";
|
|
40
41
|
import path from "node:path";
|
|
@@ -46,7 +47,7 @@ export const name = "dpharness";
|
|
|
46
47
|
/** The dsh web server service used to register HTTP routes. */
|
|
47
48
|
export const inject = ["webServer"];
|
|
48
49
|
|
|
49
|
-
export const VERSION = "0.6.
|
|
50
|
+
export const VERSION = "0.6.1";
|
|
50
51
|
|
|
51
52
|
/**
|
|
52
53
|
* 本插件在 npm 上的包名 —— 与 dsh 的插件 id(上面的 `name = "dpharness"`)**不是一回事**,
|
|
@@ -75,6 +76,18 @@ export const SHAPE_REV = 4;
|
|
|
75
76
|
*/
|
|
76
77
|
const STARTED_AT = Date.now() - Math.round(process.uptime() * 1000);
|
|
77
78
|
|
|
79
|
+
/**
|
|
80
|
+
* Identity of this host process, renewed on every start.
|
|
81
|
+
*
|
|
82
|
+
* `STARTED_AT` alone turned out to be a weak proof of "a restart happened":
|
|
83
|
+
* it is a wall-clock value, so a clock step or a later install refreshing the
|
|
84
|
+
* client-side timestamp can make the comparison lie. A boot id has no such
|
|
85
|
+
* ambiguity — it is generated once per process and can only differ when the
|
|
86
|
+
* process really changed. The timestamp is kept as the fallback for clients
|
|
87
|
+
* that already stored a pending record before this field existed.
|
|
88
|
+
*/
|
|
89
|
+
const BOOT_ID = randomUUID();
|
|
90
|
+
|
|
78
91
|
/**
|
|
79
92
|
* Profile used for installs.
|
|
80
93
|
*
|
|
@@ -1976,6 +1989,7 @@ export function apply(ctx) {
|
|
|
1976
1989
|
upstream: UPSTREAM,
|
|
1977
1990
|
tracker: TRACK,
|
|
1978
1991
|
startedAt: STARTED_AT,
|
|
1992
|
+
bootId: BOOT_ID,
|
|
1979
1993
|
routes: [
|
|
1980
1994
|
"/api/dpharness/search",
|
|
1981
1995
|
"/api/dpharness/best",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-dpharness",
|
|
3
3
|
"icon": "./icon.svg",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.1",
|
|
5
5
|
"description": "Curated dpharness.com plugin catalog inside the DeepSeek Harness Web GUI: a conversation-view tab, a sidebar entry and a dismissible site-wide floating panel, offering a searchable full catalog, a monthly by-category shortlist, a daily pick and an update check (this plugin plus every installed plugin) with a red-dot reminder, with one-click install via dshmarket or the dsh CLI. Includes a settings page (General row + Plugins tab) for the widget visibility, the daily pick, the update check and the opt-out telemetry relay covering the full install funnel.",
|
|
6
6
|
"author": "zhanghao3693 <zhanghao3693@qq.com>",
|
|
7
7
|
"repository": {
|