dsh-light-guard 0.7.3 → 0.7.5

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 CHANGED
@@ -6,6 +6,17 @@
6
6
 
7
7
  ---
8
8
 
9
+ ## v0.7.5 (2026-11-28)
10
+ - **发现的问题**:开启实验性功能「流式输出帧节流(`expStreamCoalesceMs`)」后,当用户把 DSH 切到后台窗口时,Chromium 会把后台页面的 `setTimeout` 节流拉长到 ≥ 1 秒/次,导致流事件在前端队列里严重积压;切回 DSH 后,早已在后端完成的会话仍会慢半拍逐条补放动画。
11
+ - **改了什么**:
12
+ - 在流节流分支增加 `document.hidden` 检测:窗口处于后台隐藏状态时自动跳过 `setTimeout` 节流,直接同步更新数据状态(后台本就不触发屏幕重绘,零额外渲染开销,同时彻底消除切回前台后的动画补放延迟)。
13
+
14
+ ## v0.7.4 (2026-11-27)
15
+ - **发现的问题**:高频实用功能「软刷新前端界面」此前藏在第二个 Tab「体检与快照」里,打开插件第一屏不容易发现;若直接挤在标题行右侧又容易把标题和徽章挤换行。
16
+ - **改了什么**:
17
+ - 在顶部驾驶舱 4 个 KPI 指标卡正下方新增独立**「快捷操作栏」**,将「立即体检」与「↻ 软刷新前端界面」等高舒展并排呈现,既突出醒目又不挤占标题和指标卡宽度;
18
+ - 软刷新确认卡片与减负回执同步支持在顶部操作栏直接展开与展示,并在真机 DSH 桌面端完成无报错端到端验证。
19
+
9
20
  ## v0.7.3 (2026-11-27)
10
21
  - **发现的问题**:
11
22
  1. 设置页中部分深色强调字(`#b45309` / `#059669`)在 DSH 深色模式下对比度偏低;
package/lib/client.js CHANGED
@@ -20,7 +20,7 @@ window.__ModuleLoader__.load({
20
20
  var h = React.createElement;
21
21
 
22
22
  var PLUGIN_NAME = "dsh-light-guard";
23
- var VERSION = "0.7.3";
23
+ var VERSION = "0.7.5";
24
24
  var API_PREFIX = "dsh-light-guard";
25
25
  var LOCAL_CACHE_KEY = "dsh.lightGuard.config.v1";
26
26
  var SOFT_RELOAD_KEY = "dsh.lightGuard.softReload.v1";
@@ -346,7 +346,8 @@ window.__ModuleLoader__.load({
346
346
  } else if (frame.type === "entry" && frame.entry !== undefined) {
347
347
  slimRecords([frame.entry]);
348
348
  var delay = Number(runtimeConfig.expStreamCoalesceMs) || 0;
349
- if (delay > 0) {
349
+ var isHidden = typeof document !== "undefined" && document.hidden === true;
350
+ if (delay > 0 && !isHidden) {
350
351
  var now = Date.now();
351
352
  if (now - lastEntryAt < delay) {
352
353
  await new Promise(function (r) { setTimeout(r, delay - (now - lastEntryAt)); });
@@ -690,7 +691,7 @@ window.__ModuleLoader__.load({
690
691
  var snapLabel = _snapLabel[0], setSnapLabel = _snapLabel[1];
691
692
  var _liveDom = React.useState({ domNodes: 0, longTasks: 0, maxLtMs: 0 });
692
693
  var liveDom = _liveDom[0], setLiveDom = _liveDom[1];
693
- var _srConfirm = React.useState(false);
694
+ var _srConfirm = React.useState(null); // "hero" | "doctor" | null
694
695
  var srConfirm = _srConfirm[0], setSrConfirm = _srConfirm[1];
695
696
  var _srState = React.useState(readSoftReloadState);
696
697
  var srState = _srState[0], setSrState = _srState[1];
@@ -1088,6 +1089,30 @@ window.__ModuleLoader__.load({
1088
1089
  { id: "archive", label: "冷归档库" + (archList ? " (" + archList.totalCount + ")" : "") }
1089
1090
  ];
1090
1091
 
1092
+ var heroIsDesktop = typeof window !== "undefined" && window.location && window.location.protocol === "dsh-app:";
1093
+ var heroSr = readSoftReloadState();
1094
+ var heroSrFailed = heroSr && heroSr.status === "failed";
1095
+ var heroSrVerified = heroSr && heroSr.status === "verified";
1096
+
1097
+ function renderSoftReloadConfirmBox(isDesktopEnv, verifiedEnv) {
1098
+ return h("div", { style: { marginTop: "10px", fontSize: "12px", padding: "10px 12px", borderRadius: "8px", background: "rgba(245,158,11,0.1)", border: "1px solid rgba(245,158,11,0.4)", lineHeight: 1.6 } },
1099
+ h("div", { style: { fontWeight: 700, marginBottom: "4px", color: "#f59e0b" } },
1100
+ isDesktopEnv && !verifiedEnv ? "使用前必看(请花 3 秒确认,别担心数据安全)" : "确认立即软刷新前端界面?"
1101
+ ),
1102
+ h("div", null, "1. 作用:仅重载前端界面释放 Chromium 渲染内存,不重启后端、不中断后台正在运行的 Agent 任务;输入栏未发送的草稿请先复制保存。"),
1103
+ isDesktopEnv && !verifiedEnv
1104
+ ? h("div", null, "2. 兼容提醒:如果您装了多个第三方插件,个别插件在桌面端重载时可能触发 web-boot 报错弹窗。")
1105
+ : null,
1106
+ isDesktopEnv && !verifiedEnv
1107
+ ? h("div", null, "3. 万一弹窗别慌:您的数据、会话和插件绝对不会丢失——直接点弹窗里的「重启」(不要点「禁用第三方插件」),几秒即可恢复正常;本插件会自动记住冲突,后续不再推荐。")
1108
+ : null,
1109
+ h("div", { style: { display: "flex", gap: "8px", marginTop: "8px" } },
1110
+ h("button", { style: btnPrimary, onClick: executeSoftReload }, "我已知晓,开始软刷新"),
1111
+ h("button", { style: btnBase, onClick: function () { setSrConfirm(null); } }, "取消")
1112
+ )
1113
+ );
1114
+ }
1115
+
1091
1116
  return h("div", { style: { fontSize: "13px", lineHeight: 1.5, maxWidth: "820px" } },
1092
1117
 
1093
1118
  // ── Hero Performance Cockpit ──
@@ -1109,11 +1134,6 @@ window.__ModuleLoader__.load({
1109
1134
  ? h(Pill, { bg: "rgba(245,158,11,0.18)", color: "#f59e0b" }, "后端 v" + (verInfo.hostVersion || "旧版") + " · 待热重载/重启")
1110
1135
  : null
1111
1136
  ),
1112
- h("button", {
1113
- style: Object.assign({}, btnPrimary, { padding: "6px 14px", fontWeight: 600 }),
1114
- disabled: scanning,
1115
- onClick: function () { doScan(true); }
1116
- }, scanning ? "扫描中…" : "立即体检")
1117
1137
  ),
1118
1138
  h("div", { style: { fontSize: "12px", opacity: 0.78, marginBottom: "10px" } },
1119
1139
  "零后台轮询 · 官方 API 冷归档 · 前后端内存归因 · 可调参流瘦身"
@@ -1137,7 +1157,46 @@ window.__ModuleLoader__.load({
1137
1157
  )
1138
1158
  )
1139
1159
  )
1140
- )
1160
+ ),
1161
+ // ── Dedicated Quick Action Bar below KPIs ──
1162
+ h("div", {
1163
+ style: {
1164
+ display: "flex",
1165
+ justifyContent: "space-between",
1166
+ alignItems: "center",
1167
+ gap: "10px",
1168
+ flexWrap: "wrap",
1169
+ marginTop: "12px",
1170
+ paddingTop: "11px",
1171
+ borderTop: "1px solid rgba(128,128,128,0.14)"
1172
+ }
1173
+ },
1174
+ h("div", { style: { display: "flex", alignItems: "center", gap: "8px", flexWrap: "wrap" } },
1175
+ h("button", {
1176
+ style: Object.assign({}, btnPrimary, { padding: "7px 16px", fontWeight: 600 }),
1177
+ disabled: scanning,
1178
+ onClick: function () { doScan(true); }
1179
+ }, scanning ? "扫描中…" : "立即体检"),
1180
+ h("button", {
1181
+ style: Object.assign({}, btnBase, {
1182
+ padding: "7px 14px",
1183
+ fontWeight: 600,
1184
+ borderColor: heroSrFailed ? "rgba(245,158,11,0.5)" : "rgba(59,130,246,0.45)",
1185
+ background: heroSrFailed ? "rgba(245,158,11,0.1)" : "rgba(59,130,246,0.09)",
1186
+ color: heroSrFailed ? "#f59e0b" : "#3b82f6"
1187
+ }),
1188
+ onClick: function () { setSrConfirm(srConfirm === "hero" ? null : "hero"); }
1189
+ }, (heroSrFailed ? "↻ 重新测试软刷新" : "↻ 软刷新前端界面") + (heroSrVerified ? " ✓" : ""))
1190
+ ),
1191
+ h("div", { style: { fontSize: "11px", opacity: 0.72 } },
1192
+ heroSrVerified && typeof heroSr.beforeDom === "number" && typeof heroSr.afterDom === "number"
1193
+ ? ("✓ 上次软刷新:DOM " + heroSr.beforeDom.toLocaleString() + " → " + heroSr.afterDom.toLocaleString())
1194
+ : heroSrFailed
1195
+ ? "⚠ 上次软刷新异常,建议正常重启 DSH"
1196
+ : "软刷新仅重载界面,不中断后台任务"
1197
+ )
1198
+ ),
1199
+ srConfirm === "hero" ? renderSoftReloadConfirmBox(heroIsDesktop, heroSrVerified) : null
1141
1200
  ),
1142
1201
 
1143
1202
  // Long uptime gentle reminder
@@ -1469,7 +1528,7 @@ window.__ModuleLoader__.load({
1469
1528
  ),
1470
1529
  h("button", {
1471
1530
  style: (!srFailed && memDiag.suggestSoftReload) ? btnPrimary : btnBase,
1472
- onClick: function () { setSrConfirm(!srConfirm); }
1531
+ onClick: function () { setSrConfirm(srConfirm === "doctor" ? null : "doctor"); }
1473
1532
  }, srFailed ? "重新测试软刷新" : "软刷新前端界面")
1474
1533
  ),
1475
1534
  h("div", { style: { display: "grid", gridTemplateColumns: "repeat(auto-fit, minmax(220px, 1fr))", gap: "8px", marginBottom: "8px", fontSize: "12px" } },
@@ -1509,24 +1568,7 @@ window.__ModuleLoader__.load({
1509
1568
  )
1510
1569
  : null,
1511
1570
  // Clear, reassuring 2-step confirmation panel before triggering reload
1512
- srConfirm
1513
- ? h("div", { style: { marginTop: "8px", fontSize: "12px", padding: "10px 12px", borderRadius: "8px", background: "rgba(245,158,11,0.1)", border: "1px solid rgba(245,158,11,0.4)", lineHeight: 1.6 } },
1514
- h("div", { style: { fontWeight: 700, marginBottom: "4px", color: "#f59e0b" } },
1515
- isDesktop && !srVerified ? "使用前必看(请花 3 秒确认,别担心数据安全)" : "确认立即软刷新前端界面?"
1516
- ),
1517
- h("div", null, "1. 作用:仅重载前端界面释放 Chromium 渲染内存,不重启后端、不中断后台正在运行的 Agent 任务;输入栏未发送的草稿请先复制保存。"),
1518
- isDesktop && !srVerified
1519
- ? h("div", null, "2. 兼容提醒:如果您装了多个第三方插件,个别插件在桌面端重载时可能触发 web-boot 报错弹窗。")
1520
- : null,
1521
- isDesktop && !srVerified
1522
- ? h("div", null, "3. 万一弹窗别慌:您的数据、会话和插件绝对不会丢失——直接点弹窗里的「重启」(不要点「禁用第三方插件」),几秒即可恢复正常;本插件会自动记住冲突,后续不再推荐。")
1523
- : null,
1524
- h("div", { style: { display: "flex", gap: "8px", marginTop: "8px" } },
1525
- h("button", { style: btnPrimary, onClick: executeSoftReload }, "我已知晓,开始软刷新"),
1526
- h("button", { style: btnBase, onClick: function () { setSrConfirm(false); } }, "取消")
1527
- )
1528
- )
1529
- : null
1571
+ srConfirm === "doctor" ? renderSoftReloadConfirmBox(isDesktop, srVerified) : null
1530
1572
  ),
1531
1573
 
1532
1574
  h("div", { style: surfaceCard },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-light-guard",
3
- "version": "0.7.3",
3
+ "version": "0.7.5",
4
4
  "author": "unifilitence",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/",