@twinsearth/timemachine-dsh-plugin 0.2.2 → 0.2.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
@@ -1,5 +1,51 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.5 — 2026-12-03
4
+
5
+ ### 还原不中断
6
+
7
+ - 第三方插件逐个尝试安装;单个插件失败只汇总为黄色提示「安装失败,请自行手动安装!」,不再返回 `RESTORE_PLUGIN_INSTALL_FAILED` 终止还原,会话、附件、配置和工作区继续落盘。
8
+ - 失败插件保留在结果 `plugins.failed`,成功插件仍合并回归档 `package.json`;UI 在还原完成横幅展示失败插件名。
9
+
10
+ ### DSH 兼容性预检
11
+
12
+ - 新增 `src/plugin-compat.mjs`:安装前读取 npm latest 或离线 tgz 的 `engines.dsh` / DSH peer 依赖,使用内置 semver 子集与当前 DSH 客户端版本比对。
13
+ - 当前 DSH 版本从 `resources/runtime/primary-runtime/runtime.json` 或显式传入值解析;不兼容插件标记 `PLUGIN_DSH_INCOMPATIBLE`、提示并跳过,不再安装后才被下次启动拒绝。
14
+
15
+ ### 缺失存储盘
16
+
17
+ - Windows 下工作区目标路径所在盘符不存在时,`/plan` 返回 `path_issues`,计划弹窗红字提示「本机没有该存储盘」并禁用确认,要求修改工作区文件夹。
18
+ - `/restore` 与 `applyRestore` 二次校验盘符,避免绕过 UI 写入不存在的盘;`/import` 同时返回导入点的缺失盘提示。
19
+
20
+ ### 标题栏入口
21
+
22
+ - Windows 原生「应用」菜单补丁项显式 `visible: true`,保持「DSH一键还原点」可见。
23
+ - 纯插件标题栏备用入口改为常驻:`CAPTION_AUTO_HIDE_MS` 改为 `CAPTION_DISCOVERY_MS`,只在宿主标题栏从未出现时停止观察,不再 30 秒后移除按钮;标题栏重绘后会补挂。
24
+
25
+ ### 验证与发布
26
+
27
+ - `npm test` 32/32;`npm run check` 30/30;`npm run pack-check` 通过。
28
+ - GitHub 与 npm 双通道发布 `0.2.5`。
29
+
30
+ ## 0.2.3 — 2026-12-03
31
+
32
+ ### 版本与统计
33
+
34
+ - 面板右上角新增 `Time Machine v0.2.3` 版本胶囊,版本来自 `/status` 的 `version` 字段。
35
+ - 版本胶囊旁新增 `在线 X · 7日 Y · 安装 Z` 统计胶囊,数据来自本地 `/stats` 代理的独立租约服务。
36
+ - 新增 `src/version.mjs` 作为版本单一来源;`plugin.json`、`package.json`、README、CHANGELOG 同步到 `0.2.3`。
37
+
38
+ ### 安装身份与租约
39
+
40
+ - 新增 `src/telemetry.mjs`:安装目录首次运行生成随机 `.timemachine-install-token`;同目录重启复用,换目录/重装换新 token 再计数。目录只读时退回 `sha256(路径 + 主机名)` 稳定摘要。
41
+ - 客户端启动随机等待 1–11 秒再领租约;399 分钟租约;服务端按 3 小时周期在 55%–95% 区间随机排回执时刻。
42
+ - 回执失败 2–6 分钟补投,连续 3 次失败后下一个周期再领;本地 400 分钟未续上按 1–60 秒、100 秒、300 秒、1000 秒重连,连续三次失败后等 400 分钟再续。
43
+ - 服务端 `POST /v1/lease`、`POST /v1/receipt`、`POST /v1/miss`、`GET /v1/stats`、`GET /health`;独立 SQLite,不修改既有 `fang-lease` 服务。
44
+
45
+ ### 发布
46
+
47
+ - 四方发布 `0.2.3`:Git tag、GitHub Release、GitHub Package、npm。
48
+
3
49
  ## 0.2.2 — 2026-12-03
4
50
 
5
51
  ### 滚动与默认文件夹树
package/README.md CHANGED
@@ -1,8 +1,12 @@
1
1
  # @twinsearth/timemachine-dsh-plugin
2
2
 
3
+ [![CI](https://github.com/TwinsEarth/TimeMachine-dsh-plugin/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/TwinsEarth/TimeMachine-dsh-plugin/actions/workflows/ci.yml)
4
+ [![npm](https://img.shields.io/npm/v/@twinsearth/timemachine-dsh-plugin.svg)](https://www.npmjs.com/package/@twinsearth/timemachine-dsh-plugin)
5
+ [![DSH](https://img.shields.io/badge/DSH-0.2.x-111827)](https://github.com/deepseek-ai/deepseek-harness)
6
+
3
7
  DSH 一键还原点(Time Machine)。它把 DSH 客户端的会话、工作区、配置与插件清单打包成一个可迁移的还原点,并在需要时把整台机器上的 DSH 恢复成还原点里的样子。
4
8
 
5
- - 版本:`0.2.2`
9
+ - 版本:`0.2.5`
6
10
  - 宿主:DeepSeek Harness(DSH)桌面客户端 `0.2.x`
7
11
  - 平台:Windows / macOS / Linux(Windows 默认目录,macOS/Linux 由用户选择目录)
8
12
  - 许可:MIT
@@ -66,6 +70,28 @@ DSH 一键还原点:
66
70
 
67
71
  接口为 `POST /api/twinsearth/timemachine/repair-guides`,省略 `file` 时修复全部还原点;传 `file` 时只修复该归档,且必须位于当前保存文件夹内。
68
72
 
73
+ ### 1.8 版本号、在线/7日/安装统计与租约
74
+
75
+ 完整面板右上角固定显示两枚胶囊:
76
+
77
+ - `Time Machine v0.2.5`:版本号来自服务端 `status.version`,不是客户端硬编码;插件更新后随包变化。
78
+ - `在线 X · 7日 Y · 安装 Z`:通过本地 `GET /api/twinsearth/timemachine/stats` 代理独立统计服务。
79
+
80
+ 统计口径:
81
+
82
+ - **当前在线**:399 分钟租约未过期的去重安装数,即最近 399 分钟有过回执。
83
+ - **7 天内活跃**:`lastSeen` 落在最近 7 天内的安装数。
84
+ - **历史安装数**:安装事件累计,单调只增。每份安装首次运行生成随机 token,写入插件安装目录的 `.timemachine-install-token`;同一目录重启复用 token,只算一次;换目录/重装会生成新 token,再计一次。
85
+ - 安装目录只读时退回 `sha256(安装路径 + 主机名)` 摘要:重启稳定,但同一路径重装不再增加计数,这是唯一降级情况。
86
+
87
+ 租约与回执:
88
+
89
+ - 服务端把 3 小时划为一个周期,在周期的 55%–95% 之间为每台在线机器随机排一个回执时刻,避免整点齐发。
90
+ - 客户端启动后随机等待 1–11 秒再领租约;到点回执成功后续 399 分钟。
91
+ - 回执失败每隔 2–6 分钟补投一次;连续 3 次失败放回队列,下一个周期再领。
92
+ - 本地 400 分钟没有续上:先随机 1–60 秒重连,再按 100 秒、300 秒、1000 秒各试一次;连续三次失败后等 400 分钟再进入下一轮。
93
+ - 统计服务地址可用 `TIMEMACHINE_STATS_URL` 覆盖;默认地址随插件发布。
94
+
69
95
  ### 2.1 用户插件:内置与实验性
70
96
 
71
97
  还原点记录 `dsh.profile.bundles`、`dependencies` 与 `cordis.patch.yml` 的插件行,包含:
@@ -162,8 +188,8 @@ sessions/<project-key>/<encoded-session-id>/
162
188
 
163
189
  1. **DSH 通用设置**:`设置 -> 通用` 里新增「DSH 一键还原点」一行,可直接「立即备份」「一键还原」或「打开完整面板」。「一键还原」先打开还原计划确认弹窗,确认后还原最近一份手动/自动还原点,并自动打开还原后的会话。
164
190
  2. **左上角侧栏**:`sidebar.panellist` 顶部新增入口,位置在品牌行下方、会话列表上方。macOS 显示「时间机器」,Windows 显示「一键还原点」,点击打开完整面板。该入口在插件启动 **10 秒后自动隐藏**,让出导航位;之后仍可从通用设置行点「打开完整面板」。
165
- 3. **Windows 标题栏(纯插件备用入口)**:插件运行时在左上角「应用 / 编辑」右侧追加「DSH一键还原点」按钮,点击直接打开完整面板。该按钮在启动 **30 秒后自动隐藏**。它不需要改 `app.asar`;只在 DSH 桌面客户端存在 `[data-windows-menu]` 时生效,用浏览器打开 Web UI 不会显示。
166
- 4. **原生应用菜单(需求 4.2 的精确入口)**:包内提供 `scripts/host-menu-patch.mjs`,在 DSH 的 `app.asar` 的「应用 -> 开发者工具」后插入「DSH一键还原点」,点击后调用插件暴露的 `window.__DSH_TIMEMACHINE_OPEN__()` 打开面板。
191
+ 3. **Windows 标题栏(纯插件备用入口)**:插件运行时在左上角「应用 / 编辑」右侧追加「DSH一键还原点」按钮,点击直接打开完整面板。该按钮**常驻,不再自动隐藏**;标题栏重绘后会补挂。它不需要改 `app.asar`;只在 DSH 桌面客户端存在 `[data-windows-menu]` 时生效,用浏览器打开 Web UI 不会显示。
192
+ 4. **原生应用菜单(需求 4.2 的精确入口)**:包内提供 `scripts/host-menu-patch.mjs`,在 DSH 的 `app.asar` 的「应用 -> 开发者工具」后插入显式 `visible: true` 的「DSH一键还原点」,点击后调用插件暴露的 `window.__DSH_TIMEMACHINE_OPEN__()` 打开面板。
167
193
 
168
194
  原生菜单必须由宿主补丁实现,因为 DSH 桌面端的「应用」菜单由主进程硬编码(关于/检查更新/管理 dsh 命令/开发者工具/重启应用/退出),插件 API 没有“向应用菜单追加菜单项”的能力,`windowsMenu` IPC 也只接受 `application`/`edit` 两个菜单名。标题栏第三个按钮是纯插件的降级入口;如果要求严格出现在「应用 -> 开发者工具」下面,执行下面的补丁。本机真实客户端已执行;换一台机器部署时仍需执行一次。
169
195
 
@@ -243,7 +269,7 @@ npm run check # 静态交付检查
243
269
  npm run pack-check
244
270
  ```
245
271
 
246
- 测试覆盖:手动/自动创建、范围选择、保留份数、计划与还原、跳过插件安装、导入、设置持久化、损坏归档拒绝、HTTP 路由挂载、客户端 bundle 槽位注册、侧栏入口 10 秒自动隐藏与标题栏按钮 30 秒自动隐藏、标题随系统自适应、locale 五项详情、文件夹结构树与单分支展开、会话引导修复、运行中 `workspaceRegistry` 实时注册。真实客户端验收记录见 `docs/TESTPLAN.md`。
272
+ 测试覆盖:手动/自动创建、范围选择、保留份数、计划与还原、插件安装失败不中断、DSH 版本兼容性跳过、导入、设置持久化、损坏归档拒绝、缺失盘符检测、HTTP 路由挂载、客户端 bundle 槽位注册、侧栏入口 10 秒自动隐藏与标题栏入口常驻、标题随系统自适应、locale 五项详情、文件夹结构树与单分支展开、会话引导修复、运行中 `workspaceRegistry` 实时注册。真实客户端验收记录见 `docs/TESTPLAN.md`。
247
273
 
248
274
  ## 数据与安全
249
275
 
@@ -263,7 +289,9 @@ npm run pack-check
263
289
  | 提示同名 Session ID 冲突 | 目标 DSH 已有同一个 Session ID 的会话;还原点用于新机器/新工作区时不会出现。可先归档或移走旧会话再还原 |
264
290
  | 标题栏没有「DSH一键还原点」 | 该按钮只存在于 DSH 桌面客户端;用浏览器访问 Web UI 时没有 `[data-windows-menu]`。桌面端仍不出现时,改用侧栏入口或执行下面的原生菜单补丁 |
265
291
  | 原生菜单项不出现 | 目标机必须完全退出 DSH 后,对 `D:\DSH\resources\app.asar` 执行 `host-menu-patch.mjs` 并重启;只装插件不会自动改宿主菜单。本机真实 asar 已补丁,可用 `--check` 复核 |
266
- | 第三方插件安装失败 | 检查网络与 npm registry;可改用「同时备份插件安装包」离线还原 |
292
+ | 还原/导入提示「本机没有该存储盘」 | 还原点来自另一台机器,工作区路径在 `D:` / `E:` 等本机不存在的盘。按红字提示修改工作区文件夹后再确认;不要强行使用不存在的盘符 |
293
+ | 第三方插件安装失败 | 现在只显示黄色提示「安装失败,请自行手动安装!」,不会中断会话/配置还原;按提示手动安装该插件,或改用「同时备份插件安装包」离线还原 |
294
+ | 插件因 DSH 版本不兼容被跳过 | 插件声明了 `engines.dsh`(或 DSH peer 依赖),当前客户端版本不满足。升级 DSH 或换兼容版本插件后重试;该插件不会阻塞其余还原 |
267
295
  | 还原点过大 | 改用「活跃会话」范围,或关闭附件备份 |
268
296
 
269
297
  ## 版本
@@ -6,6 +6,8 @@
6
6
  lib/index.js Node 入口,re-export src/plugin.mjs
7
7
  lib/client.js 浏览器 bundle,注册三个 UI 槽位 + Windows 标题栏备用按钮
8
8
  src/plugin.mjs Cordis apply / HTTP 路由 / 单操作互斥
9
+ src/telemetry.mjs 安装 token、租约回执状态机、远程统计缓存
10
+ src/version.mjs 面板与 health 共用的版本单一来源
9
11
  src/service.mjs 设置、状态、创建、计划、还原、导入、定时器
10
12
  src/point.mjs 还原点归档格式、创建、读取、列表、清理、导入
11
13
  src/guide-repair.mjs 已有还原点内的会话引导校验与重建
@@ -21,6 +23,25 @@ src/util/* 路径、哈希、原子写、安全文件名
21
23
 
22
24
  服务端只依赖 Node 标准库;客户端只依赖宿主提供的 `react`。
23
25
 
26
+ ## 1.1 安装身份与租约统计
27
+
28
+ ```
29
+ 插件安装目录/.timemachine-install-token 随机 token,首次运行生成
30
+ │
31
+ ├─ 同目录重启:复用 token,不重复计安装
32
+ ├─ 换目录/重装:新 token,再计一次
33
+ └─ 目录只读:sha256(路径 + 主机名) 回退(同路径重装不再计数)
34
+
35
+ 客户端启动 1–11 s
36
+ -> POST /v1/lease(token/version/platform/arch)
37
+ -> 服务端返回 399 分钟租约 + 3 小时周期 55%–95% 的随机 next_receipt_at
38
+ -> 到点 POST /v1/receipt,续租并排下一周期
39
+ -> 失败 2–6 分钟补投,连续 3 次失败下一周期再 claim
40
+ -> 本地 400 分钟未续上:1–60 s、100 s、300 s、1000 s 重连;仍失败等 400 分钟
41
+ ```
42
+
43
+ 统计服务是独立 Debian 12 + Python 标准库 + SQLite 服务(`server/timemachine_lease.py`,默认 `:38081`),不读写既有 `fang-lease` 的库或进程。`GET /v1/stats` 返回 `online`(399 分钟租约内去重安装)、`sevenDay`、`installs`(累计安装)。
44
+
24
45
  ## 2. 数据布局
25
46
 
26
47
  ```
@@ -126,7 +147,7 @@ service.restore -> restore.restorePoint
126
147
 
127
148
  `layout.selectPanel('timemachine')` 依赖 `main` 注册项的 `options.key === 'timemachine'`。客户端必须声明 `inject: ['slots', 'layout']`;缺少 `layout` 时 Cordis 会在访问 `ctx.layout` 时抛 `cannot get property "layout" without inject`,整个客户端模块不会激活。`uiWorkspace` / `sessions` 用 `ctx.get` 可选读取,不加入硬注入;直接属性访问 `ctx.uiWorkspace` 会抛 `cannot get property "uiWorkspace" without inject`,这也是 0.1.0 修复过的坑。
128
149
 
129
- 除槽位外,`installCaptionEntry` 在 Windows 桌面客户端的 `[data-windows-menu]` open shadowRoot 里追加 `data-timemachine-caption` 按钮。宿主节点不存在(浏览器 Web UI)时用 `MutationObserver` 等 30 秒后静默放弃;组件卸载只移除自己追加的按钮,不碰宿主已有「应用 / 编辑」按钮。
150
+ 除槽位外,`installCaptionEntry` 在 Windows 桌面客户端的 `[data-windows-menu]` open shadowRoot 里追加 `data-timemachine-caption` 按钮。该按钮常驻,不设自动隐藏定时器;`MutationObserver` 在标题栏重绘后补挂。宿主节点从未出现(浏览器 Web UI)时,观察器在 30 秒后发现仍无按钮才静默停止;组件卸载只移除自己追加的按钮,不碰宿主已有「应用 / 编辑」按钮。
130
151
 
131
152
  ### 6.1 完整面板的文件夹详情
132
153
 
@@ -170,7 +191,9 @@ service.restore -> restore.restorePoint
170
191
  - 服务端所有写操作经过 `guarded` 单操作互斥;并发的第二个请求返回 409。
171
192
  - 归档写入先写临时文件再 rename,避免半成品被列为还原点。
172
193
  - 还原写入前生成预还原副本;校验失败回滚新增文件、删除新建空目录。
173
- - pnpm 安装失败时回滚 `package.json` / `cordis.patch.yml`;`node_modules` 可能处于部分更新状态,这是已知权衡,会在结果里返回 `stage: plugin-install`。
194
+ - 第三方插件逐个安装;单个安装失败只记入 `plugins.failed` 并产生黄色提示「安装失败,请自行手动安装!」,会话、附件、配置和工作区继续应用。只有 profile 不存在或离线包结构不可读等致命错误才返回 `stage: plugin-install` 并恢复 `package.json` / `cordis.patch.yml`;`node_modules` 可能处于部分更新状态,这是已知权衡。
195
+ - 安装前 `src/plugin-compat.mjs` 读取插件 `engines.dsh` 或 DSH peer 依赖,与 `resources/runtime/primary-runtime/runtime.json` 的 `desktopVersion` 比对;不满足时标记 `PLUGIN_DSH_INCOMPATIBLE` 并跳过,避免安装后才被 DSH 启动拒绝。
196
+ - Windows 下 `planRestore` 对每个目标工作区检查盘符是否存在;缺失时返回 `path_issues` 并让计划弹窗红字提示、禁用确认。`restorePoint` 和 `applyRestore` 均二次拒绝,防止绕过 UI 写不存在的盘。
174
197
 
175
198
  ## 8. 原生菜单补丁
176
199
 
@@ -179,7 +202,7 @@ DSH 桌面端的「应用」菜单在 `app.asar` 的 `lib/main.js` 中由 `appli
179
202
  ```
180
203
  读 app.asar header(pickle)
181
204
  定位 lib/main.js 的 toggleDevTools 块
182
- 在其后插入 { id: "twinsearth-timemachine-menu-v1", label: "DSH一键还原点", click }
205
+ 在其后插入 { id: "twinsearth-timemachine-menu-v1", label: "DSH一键还原点", visible: true, click }
183
206
  click: 取 focused/first BrowserWindow -> show/focus -> executeJavaScript("window.__DSH_TIMEMACHINE_OPEN__?.()")
184
207
  重建 data section:重排所有 packed 文件 offset
185
208
  更新 lib/main.js 的 size / integrity.hash / blocks
@@ -92,7 +92,21 @@ node scripts/host-menu-patch.mjs --app-asar "D:\DSH\resources\app.asar" --restor
92
92
  - [ ] 重启 DSH 后点击「应用 -> 开发者工具 -> DSH一键还原点」验收
93
93
  - [ ] 第三方插件真实联网 latest 安装验收
94
94
  - [x] npm 与 GitHub 发布 `0.2.1`
95
- - [ ] npm 与 GitHub 发布 `0.2.2`
95
+ - [x] npm 与 GitHub 发布 `0.2.2`
96
96
  - [ ] real DSH 面板滚动/拖动条与默认最新树的点击验收
97
97
  - [ ] 真实 DSH 面板绿色「一键修复会话引导」点击与结果验收
98
98
  - [ ] 插件管理器标题/详情在真实 DSH 中的渲染验收
99
+ - [x] 版本号、在线/7日/安装统计胶囊(静态与协议测试通过)
100
+ - [x] 399 分钟租约、3 小时随机回执、补投与 400 分钟重连(服务端单测 + 公网端到端通过)
101
+ - [x] 独立租约服务部署到 Debian 12 `43.142.74.71:38081`(systemd `timemachine-lease`)
102
+ - [x] 四方发布 `0.2.3`(Git tag、GitHub Release、GitHub Package、npm)
103
+ - [x] GitHub Actions CI(Linux/Windows/macOS matrix;SHA-256 仓库使用 `git init --object-format=sha256` 后检出)
104
+
105
+ ### 0.2.5 还原韧性
106
+
107
+ - [x] 单个第三方插件安装失败只黄色提示「安装失败,请自行手动安装!」,不中断还原
108
+ - [x] 安装前检查插件 `engines.dsh` / DSH peer 依赖,不兼容时提示并跳过
109
+ - [x] 导入/还原检测本机缺失的 Windows 存储盘,红字提示修改工作区文件夹
110
+ - [x] Windows「应用」菜单补丁项 `visible: true`;纯插件标题栏入口常驻、标题栏重绘后补挂
111
+ - [ ] 真实 DSH 客户端中「应用」菜单项与常驻标题栏按钮的点击验收
112
+ - [ ] GitHub 与 npm 双通道发布 `0.2.5`(发布完成后勾选)
package/docs/TESTPLAN.md CHANGED
@@ -174,6 +174,25 @@ npm run pack-check
174
174
  - 路由用例传 `file` 只修复指定归档,返回 `checked_points=1`、`unchanged_points=1`;全量扫描与失败归档报告待真实 UI 点击验收。
175
175
  - 真实 DSH 中点击绿色按钮、查看结果提示、选中归档被修复后结构树自动刷新仍待人工点击验收。
176
176
 
177
+ ### 3.13 0.2.3 版本、统计与租约(协议通过)
178
+
179
+ - `npm test` 26/26、`npm run check` 27/27、`npm run pack-check` 33 个文件。
180
+ - 客户端 `HeaderBadges` 显示 `Time Machine v0.2.3` 与 `在线 X · 7日 Y · 安装 Z`;`/stats` 失败时显示 `—`,不阻塞主面板。
181
+ - `ensureInstallToken` 覆盖同目录稳定、不同目录换 token、只读路径回退 `sha256(path+hostname)`;`createTelemetry` 覆盖 stats 归一化、30 秒缓存和离线降级。
182
+ - Debian 12 服务端 5 个单测通过:首次计数、同 token 不重复、回执排到下一周期、连续 3 次 miss 重排、迟到 claim 排到下一周期。
183
+ - 公网 `43.142.74.71:38081` 已验证 `/health`、`/v1/lease`、`/v1/receipt`、`/v1/miss`、`/v1/stats`;测试 token 已清理,生产统计归零。
184
+ - 真实 DSH 面板右上角显示、真实安装 token 落盘与 399 分钟续租仍待真机点击/长跑验收。
185
+
186
+ ### 3.14 0.2.5 还原韧性与兼容性(自动化通过)
187
+
188
+ - `npm test` 32/32、`npm run check` 30/30。
189
+ - 插件失败用例:两个插件均让假 runner 返回 exit 1,断言两个都被尝试、`failed.length=2`、`ok=true`、警告含「安装失败,请自行手动安装!」。
190
+ - 还原失败不中断用例:真实创建还原点后,`restorePoint` 使用失败 runner 安装第三方插件,断言 `stage=restored`、工作区已落盘、`plugin_warnings` 含黄色提示。
191
+ - 兼容性用例:manifest `engines.dsh >=9.0.0`、当前 DSH `0.2.2`,断言 runner 调用次数为 0、`PLUGIN_DSH_INCOMPATIBLE`、提示已跳过;覆盖 `>=`、`^`、`~`、`||`、预发布版本与 tgz manifest 读取。
192
+ - 缺失盘用例:`missingDriveForPath('Z:\\workspace', {platform:'win32', exists:()=>false})` 返回 `Z:`;`/plan`/`/restore` 的 `path_issues` 与 UI 红字静态断言通过。
193
+ - 标题栏用例:客户端 bundle 断言 `CAPTION_AUTO_HIDE_MS` 已移除、`CAPTION_DISCOVERY_MS=30_000`,标题栏按钮不再定时移除;原生菜单补丁静态断言 `visible: true`。
194
+ - 真实 DSH 客户端「应用」菜单点击、常驻标题栏按钮出现/点击和缺失盘现场仍未做人工点击验收。
195
+
177
196
  ## 4. 待人工验收
178
197
 
179
198
  - 安装 tarball 到真实 DSH profile `desktop` 后:
@@ -190,20 +209,27 @@ npm run pack-check
190
209
  - 插件管理器详情显示五项能力,不再回退到包名
191
210
  - 真实 DSH 桌面客户端左上角标题栏:
192
211
  - 「应用 / 编辑」右侧出现「DSH一键还原点」
212
+ - 启动 30 秒后按钮仍存在,标题栏重绘后也不会消失
193
213
  - 点击打开插件面板;关闭/卸载插件后按钮消失
194
214
  - 浏览器 Web UI 不显示该按钮(无 `[data-windows-menu]`),属预期
195
215
  - 还原计划弹窗含插件时:
196
216
  - 显示「安装并还原第三方插件」勾选框,默认勾选
197
217
  - 取消勾选后确认,服务端 `installPlugins:false`,不联网安装
218
+ - 单个插件安装失败只出现黄色「安装失败,请自行手动安装!」,其余文件/会话/配置仍完成还原
219
+ - 插件 `engines.dsh` 与当前 DSH 不兼容时,计划/结果提示并跳过
220
+ - 工作区目标盘符在本机不存在时:
221
+ - 计划弹窗出现红字「本机没有该存储盘」,确认按钮禁用
222
+ - 修改到存在的盘后可确认;直接提交无效路径时服务端拒绝
198
223
  - 真实 `D:\DSH\resources\app.asar` 原生菜单补丁已执行(`patched:true`,备份已保留);重启 DSH 后验收:
199
224
  - 「应用 -> 开发者工具」下出现「DSH一键还原点」
225
+ - 原生菜单项 `visible: true`,不隐藏
200
226
  - 点击能打开插件面板(需真实 `desktop` profile 已安装本插件)
201
227
  - 第三方插件联网安装 latest 的真实网络路径(本次未执行,避免改动真实 profile)
202
228
  - 跨平台(macOS/Linux)文件夹选择弹窗与路径映射
203
229
 
204
230
  ## 5. 回归门槛
205
231
 
206
- - `npm test` 21/21 通过
207
- - `npm run check` 27/27 通过
208
- - `npm run pack-check` tarball 内容符合 `files`(31 个文件)
232
+ - `npm test` 32/32 通过
233
+ - `npm run check` 30/30 通过
234
+ - `npm run pack-check` tarball 内容符合 `files`(34 个文件,390.3 KiB)
209
235
  - 任何失败先定位到具体断言,不通过放宽断言“修复”
package/lib/client.js CHANGED
@@ -13,7 +13,7 @@ window.__ModuleLoader__.load({
13
13
  const STYLE_ID = 'timemachine-dsh-style';
14
14
  const PANEL_ID = 'timemachine';
15
15
  const SIDEBAR_AUTO_HIDE_MS = 10_000;
16
- const CAPTION_AUTO_HIDE_MS = 30_000;
16
+ const CAPTION_DISCOVERY_MS = 30_000;
17
17
 
18
18
  async function request(path, init = {}) {
19
19
  const response = await fetch(PREFIX + path, {
@@ -165,6 +165,16 @@ window.__ModuleLoader__.load({
165
165
  .tm-pageScroll::-webkit-scrollbar-thumb:hover{background:#8b93a1;background-clip:content-box}
166
166
  .tm-pageBody{min-width:0}
167
167
  .tm-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;flex-wrap:wrap}
168
+ .tm-headRight{display:flex;align-items:center;justify-content:flex-end;gap:8px;flex-wrap:wrap;margin-left:auto;min-width:0}
169
+ .tm-headActions{flex-wrap:nowrap}
170
+ .tm-badges{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
171
+ .tm-pill{display:inline-flex;align-items:center;gap:6px;border:1px solid var(--dsh-border,#e5e7eb);background:var(--dsh-bg-primary,#fff);border-radius:999px;padding:5px 10px;font-size:12px;line-height:1;white-space:nowrap;box-shadow:0 1px 2px rgba(0,0,0,.03)}
172
+ .tm-version{font-weight:650;color:var(--dsh-text-primary,#111827)}
173
+ .tm-metrics{color:var(--dsh-text-secondary,#4b5563);font-variant-numeric:tabular-nums}
174
+ .tm-metrics b{color:var(--dsh-text-primary,#111827);font-weight:650}
175
+ .tm-metricsSep{color:var(--dsh-text-tertiary,#9ca3af);margin:0 1px}
176
+ .tm-dot{width:7px;height:7px;border-radius:999px;background:#9ca3af;display:inline-block;flex:none}
177
+ .tm-dot.online{background:#22c55e;box-shadow:0 0 0 2px rgba(34,197,94,.16)}
168
178
  .tm-title{font-size:17px;font-weight:650;letter-spacing:.01em;margin:0}
169
179
  .tm-sub{color:var(--dsh-text-secondary,#6b7280);font-size:12px;margin-top:4px;word-break:break-all}
170
180
  .tm-card{background:var(--dsh-bg-primary,#fff);border:1px solid var(--dsh-border,#e5e7eb);border-radius:12px;padding:14px;box-shadow:0 1px 2px rgba(0,0,0,.03)}
@@ -206,8 +216,10 @@ window.__ModuleLoader__.load({
206
216
  .tm-empty{border:1px dashed var(--dsh-border,#d1d5db);border-radius:10px;padding:20px;text-align:center;color:var(--dsh-text-secondary,#6b7280);font-size:12px}
207
217
  .tm-banner{border-radius:10px;padding:9px 12px;font-size:12px;display:flex;align-items:flex-start;justify-content:space-between;gap:10px}
208
218
  .tm-banner.error{background:#fef2f2;border:1px solid #fecaca;color:#991b1b}
219
+ .tm-banner.warn{background:#fffbeb;border:1px solid #fcd34d;color:#92400e}
209
220
  .tm-banner.success{background:#ecfdf5;border:1px solid #a7f3d0;color:#065f46}
210
221
  .tm-banner.info{background:#eff6ff;border:1px solid #bfdbfe;color:#1e40af}
222
+ .tm-input-error{border-color:#dc2626!important;background:#fef2f2!important;color:#991b1b!important}
211
223
  .tm-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(120px,1fr));gap:8px}
212
224
  .tm-kv{border:1px solid var(--dsh-border,#e5e7eb);border-radius:9px;padding:8px 10px;background:var(--dsh-bg-secondary,#fafafa)}
213
225
  .tm-kv b{display:block;font-size:15px;line-height:1.2;margin-bottom:2px}
@@ -238,6 +250,7 @@ window.__ModuleLoader__.load({
238
250
  .tm-sessionRow{display:flex;gap:8px;align-items:center;padding:4px 0;border-top:1px dashed var(--dsh-border,#e5e7eb);font-size:11px;flex-wrap:wrap}
239
251
  .tm-sessionRow:first-child{border-top:0}
240
252
  .tm-sessionId{font-family:ui-monospace,SFMono-Regular,Consolas,monospace;word-break:break-all}
253
+ @media (max-width:760px){.tm-headRight{width:100%;justify-content:flex-start;margin-left:0}.tm-headActions{flex-wrap:wrap}}
241
254
  @media (max-width:640px){.tm-pointActions{margin-left:0}.tm-card{padding:12px}.tm-treeHead{display:none}.tm-treeRow{grid-template-columns:14px minmax(0,1fr);row-gap:2px}.tm-treeDesc{grid-column:2;font-size:11px}}
242
255
  `;
243
256
  (doc.head ?? doc.documentElement).appendChild(style);
@@ -283,6 +296,72 @@ window.__ModuleLoader__.load({
283
296
  return { status, loading, error, refresh, setError };
284
297
  }
285
298
 
299
+ function useStats() {
300
+ const [stats, setStats] = useState(null);
301
+ const mounted = useRef(true);
302
+ const refresh = useCallback(async () => {
303
+ try {
304
+ const next = await request('/stats');
305
+ if (mounted.current) setStats(next);
306
+ return next;
307
+ } catch (caught) {
308
+ if (mounted.current) {
309
+ setStats(caught.payload ?? {
310
+ ok: false,
311
+ online: null,
312
+ sevenDay: null,
313
+ installs: null,
314
+ });
315
+ }
316
+ return null;
317
+ }
318
+ }, []);
319
+ useEffect(() => {
320
+ mounted.current = true;
321
+ void refresh();
322
+ const timer = setInterval(() => { void refresh(); }, 60_000);
323
+ return () => {
324
+ mounted.current = false;
325
+ clearInterval(timer);
326
+ };
327
+ }, [refresh]);
328
+ return stats;
329
+ }
330
+
331
+ function HeaderBadges({ status, stats }) {
332
+ const version = typeof status?.version === 'string' && status.version !== '' ? status.version : '…';
333
+ const numeric = (value) => (value === null || value === undefined || value === ''
334
+ ? null
335
+ : (Number.isFinite(Number(value)) ? Number(value) : null));
336
+ const online = numeric(stats?.online);
337
+ const sevenDay = numeric(stats?.sevenDay);
338
+ const installs = numeric(stats?.installs);
339
+ const live = stats?.ok !== false && online !== null;
340
+ return h('div', { className: 'tm-badges', 'data-tm-badges': 'true' }, [
341
+ h('span', {
342
+ key: 'version',
343
+ className: 'tm-pill tm-version',
344
+ title: 'Time Machine DSH 插件版本',
345
+ 'data-tm-version': version,
346
+ }, [
347
+ h('span', { key: 'dot', className: `tm-dot${live ? ' online' : ''}`, 'aria-hidden': 'true' }),
348
+ h('span', { key: 'label' }, `Time Machine v${version}`),
349
+ ]),
350
+ h('span', {
351
+ key: 'metrics',
352
+ className: 'tm-pill tm-metrics',
353
+ title: '当前在线:399 分钟租约内 · 7 天活跃:最近 7 天内有回执 · 安装:累计安装次数',
354
+ 'data-tm-metrics': 'true',
355
+ }, [
356
+ h('span', { key: 'o' }, ['在线 ', h('b', { key: 'ov' }, online === null ? '—' : String(online))]),
357
+ h('span', { key: 's', className: 'tm-metricsSep' }, '·'),
358
+ h('span', { key: 'w' }, ['7日 ', h('b', { key: 'wv' }, sevenDay === null ? '—' : String(sevenDay))]),
359
+ h('span', { key: 's2', className: 'tm-metricsSep' }, '·'),
360
+ h('span', { key: 'i' }, ['安装 ', h('b', { key: 'iv' }, installs === null ? '—' : String(installs))]),
361
+ ]),
362
+ ]);
363
+ }
364
+
286
365
  function PointRow({ point, busy, onRestore, onDetails, onFolder, selected = false }) {
287
366
  const p = point.point ?? {};
288
367
  return h('div', { className: `tm-point${selected ? ' selected' : ''}`, 'data-tm-point': p.kind ?? '' },
@@ -392,11 +471,19 @@ window.__ModuleLoader__.load({
392
471
  const workspaces = plan.workspaces ?? [];
393
472
  const plugins = plan.plugins ?? [];
394
473
  const packages = Object.keys(plan.plugin_packages ?? {});
474
+ const pathIssues = Array.isArray(plan.path_issues) ? plan.path_issues : [];
475
+ const pendingIssues = pathIssues.filter((issue) => (pathMap[issue.source_path] ?? issue.target_path) === issue.target_path);
395
476
  return h('div', { className: 'tm-modalMask', role: 'dialog', 'aria-modal': 'true' },
396
477
  h('div', { className: 'tm-modal' }, [
397
478
  h('h3', { key: 'h' }, '确认还原到本机'),
398
479
  h('div', { key: 'src', className: 'tm-muted' }, `${formatTime(plan.point?.created_at)} · 来自 ${plan.point?.source_machine ?? '未知机器'} · ${formatBytes(plan.bytes)}`),
399
480
  plan.cross_platform ? h(Banner, { key: 'cross', kind: 'info', title: '跨平台还原', detail: '来源与当前系统不同,工作区路径需要映射;你可以在下面直接修改。' }) : null,
481
+ pendingIssues.length > 0 ? h(Banner, {
482
+ key: 'drive',
483
+ kind: 'error',
484
+ title: '本机没有该存储盘',
485
+ detail: `${pendingIssues.map((issue) => issue.message).join(';')} 请修改工作区文件夹后再确认还原。`,
486
+ }) : null,
400
487
  h('div', { key: 'grid', className: 'tm-grid' }, [
401
488
  h('div', { key: 's', className: 'tm-kv' }, [h('b', { key: 'n' }, String(will.sessions ?? 0)), h('span', { key: 'l' }, '会话')]),
402
489
  h('div', { key: 'a', className: 'tm-kv' }, [h('b', { key: 'n' }, String(will.attachments ?? 0)), h('span', { key: 'l' }, '附件')]),
@@ -405,15 +492,19 @@ window.__ModuleLoader__.load({
405
492
  ]),
406
493
  workspaces.length === 0 ? null : h('div', { key: 'ws' }, [
407
494
  h('div', { key: 't', style: { fontWeight: 600, marginBottom: 6 } }, '工作区将导入到'),
408
- ...workspaces.map((workspace, index) => h('div', { key: workspace.source_path ?? String(index), className: 'tm-row', style: { marginBottom: 6 } }, [
409
- h('span', { key: 'l', className: 'tm-muted', style: { minWidth: 120 } }, workspace.title ?? workspace.source_title ?? '工作区'),
410
- h('input', {
411
- key: 'i',
412
- className: 'tm-input tm-grow',
413
- value: pathMap[workspace.source_path] ?? workspace.target_path,
414
- onChange: (event) => setPathMap((current) => ({ ...current, [workspace.source_path]: event.target.value })),
415
- }),
416
- ])),
495
+ ...workspaces.map((workspace, index) => {
496
+ const invalid = pendingIssues.some((issue) => issue.source_path === workspace.source_path);
497
+ return h('div', { key: workspace.source_path ?? String(index), className: 'tm-row', style: { marginBottom: 6 } }, [
498
+ h('span', { key: 'l', className: 'tm-muted', style: { minWidth: 120 } }, workspace.title ?? workspace.source_title ?? '工作区'),
499
+ h('input', {
500
+ key: 'i',
501
+ className: `tm-input tm-grow${invalid ? ' tm-input-error' : ''}`,
502
+ 'aria-invalid': invalid ? 'true' : 'false',
503
+ value: pathMap[workspace.source_path] ?? workspace.target_path,
504
+ onChange: (event) => setPathMap((current) => ({ ...current, [workspace.source_path]: event.target.value })),
505
+ }),
506
+ ]);
507
+ }),
417
508
  ]),
418
509
  will.plugins > 0 ? h('label', { key: 'plugins', className: 'tm-check', style: { marginTop: 8, padding: '8px 10px' } }, [
419
510
  h('input', { type: 'checkbox', checked: installPlugins, disabled: busy, onChange: () => setInstallPlugins((value) => !value) }),
@@ -425,7 +516,7 @@ window.__ModuleLoader__.load({
425
516
  h('ul', { key: 'warn' }, (plan.warnings ?? []).map((text, index) => h('li', { key: String(index) }, text))),
426
517
  h('div', { key: 'actions', className: 'tm-row' }, [
427
518
  h('button', { key: 'cancel', type: 'button', className: 'tm-btn', disabled: busy, onClick: onCancel }, '取消'),
428
- h('button', { key: 'go', type: 'button', className: 'tm-btn danger', disabled: busy, onClick: onConfirm }, busy ? '还原中…' : '确认还原'),
519
+ h('button', { key: 'go', type: 'button', className: 'tm-btn danger', disabled: busy || pendingIssues.length > 0, onClick: onConfirm }, busy ? '还原中…' : '确认还原'),
429
520
  ]),
430
521
  ]),
431
522
  );
@@ -493,6 +584,7 @@ window.__ModuleLoader__.load({
493
584
 
494
585
  function RestorePointBody({ compact = false, onDone = null }) {
495
586
  const { status, loading, error, refresh, setError } = useStatus();
587
+ const stats = useStats();
496
588
  const [tab, setTab] = useState('manual');
497
589
  const [options, setOptions] = useState({ includeConfig: true, includePlugins: true, includeSessions: true, includePluginPackages: false, sessionScope: 'active' });
498
590
  const [busy, setBusy] = useState('');
@@ -657,7 +749,15 @@ window.__ModuleLoader__.load({
657
749
  return null;
658
750
  }
659
751
  const imported = await request('/import', { method: 'POST', body: JSON.stringify({ file }) });
660
- setNotice({ kind: 'success', title: '还原点已导入', detail: imported.file });
752
+ if (Array.isArray(imported.path_issues) && imported.path_issues.length > 0) {
753
+ setNotice({
754
+ kind: 'error',
755
+ title: '还原点已导入,但本机没有该存储盘',
756
+ detail: `${imported.path_issues.map((issue) => issue.message).join(';')} 请在还原时修改工作区文件夹。`,
757
+ });
758
+ } else {
759
+ setNotice({ kind: 'success', title: '还原点已导入', detail: imported.file });
760
+ }
661
761
  setTab('imported');
662
762
  return imported;
663
763
  });
@@ -696,10 +796,28 @@ window.__ModuleLoader__.load({
696
796
  }),
697
797
  });
698
798
  setPlan(null);
799
+ const failedPlugins = result.plugins?.failed ?? [];
800
+ const incompatiblePlugins = (result.plugins?.skipped ?? []).filter((row) => row.reason_code === 'PLUGIN_DSH_INCOMPATIBLE');
801
+ const pluginWarnings = Array.isArray(result.plugin_warnings) ? result.plugin_warnings : [];
802
+ const warningDetail = [
803
+ ...(pluginWarnings.length > 0
804
+ ? pluginWarnings
805
+ : [
806
+ ...failedPlugins.map((row) => `${row.name}:安装失败,请自行手动安装!`),
807
+ ...incompatiblePlugins.map((row) => `${row.name}:${row.reason},已跳过安装。`),
808
+ ]),
809
+ result.display_hint,
810
+ ].filter((text) => typeof text === 'string' && text !== '').join(' ');
699
811
  setNotice({
700
- kind: result.live_registration?.ok === true ? 'success' : 'info',
701
- title: result.live_registration?.ok === true ? '还原完成,正在打开工作区' : '还原完成,需要重启 DSH',
702
- detail: result.display_hint ?? '请完全退出 DSH 客户端后重新启动。',
812
+ kind: (failedPlugins.length > 0 || incompatiblePlugins.length > 0 || pluginWarnings.length > 0) ? 'warn' : (result.live_registration?.ok === true ? 'success' : 'info'),
813
+ title: failedPlugins.length > 0
814
+ ? '安装失败,请自行手动安装!'
815
+ : incompatiblePlugins.length > 0
816
+ ? '部分第三方插件与当前 DSH 不兼容,已跳过'
817
+ : result.live_registration?.ok === true ? '还原完成,正在打开工作区' : '还原完成,需要重启 DSH',
818
+ detail: (failedPlugins.length > 0 || incompatiblePlugins.length > 0 || pluginWarnings.length > 0)
819
+ ? warningDetail
820
+ : (result.display_hint ?? '请完全退出 DSH 客户端后重新启动。'),
703
821
  });
704
822
  onDone?.(result);
705
823
  return result;
@@ -716,6 +834,7 @@ window.__ModuleLoader__.load({
716
834
  return h('div', { className: 'tm-root' },
717
835
  h('div', { className: 'tm-head' }, [
718
836
  h('div', { key: 't' }, [h('h2', { className: 'tm-title' }, panelTitle()), h('div', { className: 'tm-sub' }, '先选择保存文件夹,之后所有还原点都放在这里。')]),
837
+ h('div', { key: 'b', className: 'tm-headRight' }, h(HeaderBadges, { status, stats })),
719
838
  ]),
720
839
  h('div', { className: 'tm-card' }, [
721
840
  h('div', { key: 'h', className: 'tm-cardTitle' }, '选择还原点保存文件夹'),
@@ -739,9 +858,12 @@ window.__ModuleLoader__.load({
739
858
  h('h2', { className: 'tm-title' }, panelTitle()),
740
859
  h('div', { key: 's', className: 'tm-sub' }, `保存到 ${status?.root ?? ''} · DSH ${status?.dsh_home ?? ''} · ${counts.plugins ?? 0} 个第三方插件`),
741
860
  ]),
742
- h('div', { key: 'a', className: 'tm-row' }, [
743
- h('button', { key: 'pick', type: 'button', className: 'tm-btn ghost', disabled: busy !== '', onClick: changeRoot }, '更改文件夹'),
744
- h('button', { key: 'refresh', type: 'button', className: 'tm-btn ghost', disabled: busy !== '', onClick: () => void refresh() }, '刷新'),
861
+ h('div', { key: 'a', className: 'tm-headRight' }, [
862
+ h(HeaderBadges, { key: 'badges', status, stats }),
863
+ h('div', { key: 'actions', className: 'tm-row tm-headActions' }, [
864
+ h('button', { key: 'pick', type: 'button', className: 'tm-btn ghost', disabled: busy !== '', onClick: changeRoot }, '更改文件夹'),
865
+ h('button', { key: 'refresh', type: 'button', className: 'tm-btn ghost', disabled: busy !== '', onClick: () => void refresh() }, '刷新'),
866
+ ]),
745
867
  ]),
746
868
  ]),
747
869
  notice ? h(Banner, { kind: notice.kind, title: notice.title, detail: notice.detail, onClose: () => setNotice(null) }) : null,
@@ -939,7 +1061,15 @@ window.__ModuleLoader__.load({
939
1061
  }),
940
1062
  });
941
1063
  setPlan(null);
942
- setNote(result.live_registration?.ok === true ? '还原完成,正在打开工作区' : '还原完成,需要重启 DSH');
1064
+ const failedPlugins = result.plugins?.failed ?? [];
1065
+ const incompatiblePlugins = (result.plugins?.skipped ?? []).filter((row) => row.reason_code === 'PLUGIN_DSH_INCOMPATIBLE');
1066
+ const base = result.live_registration?.ok === true ? '还原完成,正在打开工作区' : '还原完成,需要重启 DSH';
1067
+ const failedText = failedPlugins.map((row) => `${row.name}:安装失败,请自行手动安装!`);
1068
+ const skippedText = incompatiblePlugins.map((row) => `${row.name}:${row.reason},已跳过安装。`);
1069
+ const prefix = failedText.length > 0
1070
+ ? '安装失败,请自行手动安装!'
1071
+ : skippedText.length > 0 ? '部分第三方插件与当前 DSH 不兼容,已跳过' : '';
1072
+ setNote(prefix === '' ? base : `${prefix} ${[...failedText, ...skippedText].join(' ')}`);
943
1073
  await refresh();
944
1074
  onRestoreDone?.(result);
945
1075
  } catch (caught) {
@@ -1019,7 +1149,6 @@ window.__ModuleLoader__.load({
1019
1149
  let button = null;
1020
1150
  let observer = null;
1021
1151
  let timer = null;
1022
- let hideTimer = null;
1023
1152
 
1024
1153
  const stopWatching = () => {
1025
1154
  if (observer !== null) {
@@ -1032,25 +1161,7 @@ window.__ModuleLoader__.load({
1032
1161
  }
1033
1162
  };
1034
1163
 
1035
- const hide = () => {
1036
- hideTimer = null;
1037
- if (button !== null) {
1038
- try { button.remove(); } catch { /* already gone */ }
1039
- button = null;
1040
- }
1041
- stopWatching();
1042
- };
1043
-
1044
- const scheduleHide = () => {
1045
- if (typeof window.setTimeout !== 'function') return;
1046
- hideTimer = window.setTimeout(hide, CAPTION_AUTO_HIDE_MS);
1047
- };
1048
-
1049
1164
  const cleanup = () => {
1050
- if (hideTimer !== null) {
1051
- try { window.clearTimeout(hideTimer); } catch { /* already gone */ }
1052
- hideTimer = null;
1053
- }
1054
1165
  stopWatching();
1055
1166
  if (button !== null) {
1056
1167
  try { button.remove(); } catch { /* already gone */ }
@@ -1085,18 +1196,21 @@ window.__ModuleLoader__.load({
1085
1196
  return true;
1086
1197
  };
1087
1198
 
1088
- if (mount()) {
1089
- scheduleHide();
1090
- return cleanup;
1091
- }
1092
- scheduleHide();
1199
+ // The title-bar tag is intentionally persistent: it is the always-visible
1200
+ // entry when the native "应用" menu patch is not installed. Keep the
1201
+ // observer after the first mount so a title-bar re-render re-adds the tag;
1202
+ // only a UI that never has a title bar stops watching after the timeout.
1203
+ const mountedInitially = mount();
1093
1204
  try {
1094
1205
  observer = new MutationObserver(() => {
1095
- if (!mount()) return;
1096
- stopWatching();
1206
+ mount();
1097
1207
  });
1098
1208
  observer.observe(document.body ?? document.documentElement, { childList: true, subtree: true });
1099
- timer = window.setTimeout(stopWatching, CAPTION_AUTO_HIDE_MS);
1209
+ if (!mountedInitially) {
1210
+ timer = window.setTimeout(() => {
1211
+ if (button === null) stopWatching();
1212
+ }, CAPTION_DISCOVERY_MS);
1213
+ }
1100
1214
  } catch { /* no DOM observer in a test harness */ }
1101
1215
  return cleanup;
1102
1216
  }
@@ -1210,7 +1324,7 @@ window.__ModuleLoader__.load({
1210
1324
  exports.sidebarLabel = sidebarLabel;
1211
1325
  exports.panelTitle = panelTitle;
1212
1326
  exports.SIDEBAR_AUTO_HIDE_MS = SIDEBAR_AUTO_HIDE_MS;
1213
- exports.CAPTION_AUTO_HIDE_MS = CAPTION_AUTO_HIDE_MS;
1327
+ exports.CAPTION_DISCOVERY_MS = CAPTION_DISCOVERY_MS;
1214
1328
  exports.latestLocalPoint = latestLocalPoint;
1215
1329
  exports.allPointRows = allPointRows;
1216
1330
  exports.defaultFolderFile = defaultFolderFile;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twinsearth/timemachine-dsh-plugin",
3
- "version": "0.2.2",
3
+ "version": "0.2.5",
4
4
  "description": "DSH 一键还原点:手动/自动双还原点、会话与工作区完整备份、第三方插件 latest 重装、配置迁移与一键还原、一键修复会话引导。",
5
5
  "type": "module",
6
6
  "icon": "./icon.png",