dsh-app-controls 0.5.1 → 0.6.0

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.md CHANGED
@@ -4,17 +4,17 @@
4
4
 
5
5
  # dsh-app-controls
6
6
 
7
- Adds two controls to the DeepSeek Harness (DSH) Web GUI: **quit the local `dsh web` service** and **check / update DSH**, plus a settings panel with optional **safe cache cleanup**. The update flow installs a newer version through a staging copy and an atomic swap, shows a progress dialog, then exits the service and closes the window.
7
+ Adds two controls to the DeepSeek Harness (DSH) Web GUI: **quit the local `dsh web` service** and **check / update DSH**, plus a settings panel with optional **safe cache cleanup**. Updates can be deferred (with a running-task warning), show release notes and a background notice, and the progress dialog can be minimized. The KDE tray uses a single DeepSeek-style icon, supports a custom icon, and opens plugin pages in the existing window.
8
8
 
9
9
  ## Plugin information
10
10
 
11
11
  | Field | Value |
12
12
  | --- | --- |
13
13
  | Name | `dsh-app-controls` (DeepSeek Harness app controls) |
14
- | Version | `0.5.1` |
14
+ | Version | `0.6.0` |
15
15
  | Author | Tianrun Gu ([@MiraculousGu](https://github.com/MiraculousGu)) |
16
- | Environment | DeepSeek Harness `0.2.2-rc.x` **Web profile** (currently `0.2.2-rc.4`); Linux + KDE desktop, Chrome `--app` window; Node.js 20+ |
17
- | Features | ① **Check and update DSH**: confirm, download/install in the background, progress dialog with phase / percent / elapsed time / npm activity, atomic swap, exit and close the window. ② **Quit DSH**: confirm, gracefully stop the whole local `dsh web` service, and close the window. ③ **KDE system tray** (`tray/dsh-tray.py`): status, open, check/update, restart, stop, logs, copy URL and notifications; its menu follows the DSH light/dark theme, and silent 30-minute background checks only notify when an update exists. ④ **Plugin settings**: tray on/off, per-feature visibility, a remembered default window size and **safe cache cleanup**. |
16
+ | Environment | DeepSeek Harness `0.2.2-rc.x` **Web profile** (currently `0.2.2-rc.5`); Linux + KDE desktop, Chrome `--app` window; Node.js 20+ |
17
+ | Features | ① **Check and update DSH**: running-task warning, update now or defer, release notes, background notice, minimizable progress, atomic swap, exit and close. ② **Quit DSH**: confirm, gracefully stop the local `dsh web` service, and close the window. ③ **KDE tray** (`tray/dsh-tray.py`): single instance, DeepSeek/custom icon, status/open/plugins/settings/update/restart/stop/logs/copy, theme-aware menu and silent 30-minute checks. ④ **Plugin settings**: tray and icon choice, per-feature visibility, remembered window size, update policy and **safe cache cleanup**. |
18
18
  | Repository | https://github.com/MiraculousGu/dsh-app-controls |
19
19
  | License | MIT |
20
20
 
@@ -28,8 +28,8 @@ Adds two controls to the DeepSeek Harness (DSH) Web GUI: **quit the local `dsh w
28
28
 
29
29
  ### Check and update DeepSeek Harness
30
30
 
31
- 1. Queries the npm registry and determines the newest version allowed by the running installation (this install tracks `^0.2.2-rc.1`, which currently resolves to `0.2.2-rc.3`).
32
- 2. Shows the current → new version in a dialog; after confirmation a progress dialog appears with phase, percentage, elapsed time and the latest npm activity line.
31
+ 1. Queries the npm registry and determines the newest version allowed by the running installation (this install tracks `^0.2.2-rc.1`, which currently resolves to `0.2.2-rc.5`).
32
+ 2. Shows the current → new version and GitHub release notes, warns when conversations or background jobs are still running, and lets you update now or defer for the configured time (default 60 minutes). After confirmation, a progress dialog shows phase, percentage, elapsed time and the latest npm activity line; it can be minimized to a floating pill so the page stays usable. Background checks show a toast when an update is available, but remain silent when already current.
33
33
  3. Installs the new version into a **staging copy** of the installation root, verifies the version, then atomically swaps it in. The live files stay untouched until that final swap.
34
34
  4. On success the service exits and the window closes; relaunch with the desktop shortcut to run the new version.
35
35
 
@@ -50,7 +50,11 @@ opening the Web GUI:
50
50
  - Right-click menu: **Open**, **Open Plugins**, **Plugin settings**, **Check for
51
51
  updates / Update to vX**, **Restart service**, **Stop service** (the open page
52
52
  closes its window itself), **Open logs**, **Copy URL**, **Quit tray**.
53
- - Notifications: update available/completed, service stopped, start failure. Background checks run every 30 minutes; when the installed version is already current no notification is shown.
53
+ - Notifications: update available/completed, service stopped, start failure. Background checks run at startup and every 30 minutes; an available update is announced once, while an up-to-date or failed automatic check stays silent.
54
+ - Single instance: the helper scans `/proc` for another `dsh-tray.py` and exits instead of creating a second icon.
55
+ - Icon: **DeepSeek** whale (theme-tinted) by default, **classic** power icon, or a **custom** PNG; switch it in plugin settings.
56
+ - Same-window navigation: **Open Plugins** / **Plugin settings** send an `open-view` command to the host so the existing app window navigates instead of opening a new window.
57
+ - Restarting waits for the old service to release its port before launching the replacement, so a graceful shutdown cannot leave a half-started service.
54
58
  - The tray menu follows the DSH light/dark theme (reading the `ui-theme` preference and the system palette) and rebuilds its icons when the theme changes.
55
59
  - At login the helper waits for Plasma's tray to become ready and pins itself into the KDE panel's shown items, so KDE does not leave it in the expanded/overflow area.
56
60
  - The helper talks to the host over
@@ -66,11 +70,13 @@ Start it with `python3 tray/dsh-tray.py`, diagnose with
66
70
 
67
71
  Open **Plugins → DeepSeek Harness 应用控制** and use the settings section at the bottom (the tray menu's **Plugin settings** opens it too):
68
72
 
69
- - **System tray icon** — enables/disables the tray helper and its login autostart.
73
+ - **System tray** — enables/disables the tray helper and its login autostart.
74
+ - **Tray icon** — DeepSeek, classic, or custom PNG path.
70
75
  - **Button visibility** — check/update button, quit button, conversation-header entry and main-interface top-right entry.
71
76
  - **Default window size** — width/height, **Remember current size** and **Use automatic size**. Applied the next time a window opens.
77
+ - **Update settings** — background auto-check (30 minutes) and default defer duration (5 minutes to 7 days).
72
78
 
73
- Settings live in `~/.local/state/dsh-app-controls/settings.json` and are shared by the host, tray and launcher. Tray enable/disable and the window size are applied on the next DSH start/window launch; button visibility changes immediately. The launcher uses a dedicated Chrome profile (`~/.local/share/dsh-web-chrome`) so the saved `--window-size` is reliably applied; DSH authentication is still seeded by the launch token.
79
+ Settings live in `~/.local/state/dsh-app-controls/settings.json` and are shared by the host, tray and launcher. Tray enable/disable and the tray icon apply immediately; the default window size applies on the next window launch, and button visibility changes immediately. The launcher uses a dedicated Chrome profile (`~/.local/share/dsh-web-chrome`) so the saved `--window-size` is reliably applied; DSH authentication is still seeded by the launch token.
74
80
 
75
81
  ### Cache cleanup
76
82
 
@@ -141,10 +147,10 @@ MIT © 2026 Tianrun Gu. See [LICENSE](LICENSE).
141
147
  | 项目 | 内容 |
142
148
  | --- | --- |
143
149
  | 名称 | `dsh-app-controls`(DeepSeek Harness 应用控制) |
144
- | 版本 | `0.5.1` |
150
+ | 版本 | `0.6.0` |
145
151
  | 作者 | Tianrun Gu([@MiraculousGu](https://github.com/MiraculousGu)) |
146
- | 适用环境 | DeepSeek Harness `0.2.2-rc.x` 的 **Web profile**(当前 `0.2.2-rc.4`);Linux + KDE 桌面、Chrome `--app` 应用窗口;Node.js 20+ |
147
- | 功能 | ① **检查并更新 DSH**:确认后后台下载安装,进度弹窗显示阶段 / 百分比 / 已用时 / npm 活动日志,完成后原子切换、退出服务并自动关窗。② **退出 DSH**:确认后优雅结束整个本地 `dsh web` 服务并自动关窗。③ **KDE 系统托盘**(`tray/dsh-tray.py`):状态、打开、检查/更新、重启、停止、日志、复制地址与通知;菜单随 DSH 明暗主题切换,后台每 30 分钟静默检查,只有发现新版本才通知。④ **插件设置**:托盘开关、各功能显示/隐藏、可记住的默认启动窗口大小,以及**安全缓存清理**。 |
152
+ | 适用环境 | DeepSeek Harness `0.2.2-rc.x` 的 **Web profile**(当前 `0.2.2-rc.5`);Linux + KDE 桌面、Chrome `--app` 应用窗口;Node.js 20+ |
153
+ | 功能 | ① **检查并更新 DSH**:运行任务风险提示、立即更新或推迟、更新说明、后台提示、可最小化进度、原子切换、退出并关窗。② **退出 DSH**:确认后优雅结束本地 `dsh web` 服务并自动关窗。③ **KDE 托盘**(`tray/dsh-tray.py`):单实例、DeepSeek/自定义图标、状态/打开/插件/设置/更新/重启/停止/日志/复制、主题菜单与 30 分钟静默检查。④ **插件设置**:托盘与图标、功能显示、窗口大小、更新策略与**安全缓存清理**。 |
148
154
  | 仓库 | https://github.com/MiraculousGu/dsh-app-controls |
149
155
  | 许可证 | MIT |
150
156
 
@@ -158,8 +164,8 @@ MIT © 2026 Tianrun Gu. See [LICENSE](LICENSE).
158
164
 
159
165
  ### 检查并更新 DeepSeek Harness
160
166
 
161
- 1. 查询 npm registry,确定当前安装允许更新的最新版本(本安装跟踪 `^0.2.2-rc.1`,当前解析为 `0.2.2-rc.3`)。
162
- 2. 弹窗显示当前版本 → 新版本;确认后进入进度弹窗(阶段、百分比、已用时、npm 活动日志)。
167
+ 1. 查询 npm registry,确定当前安装允许更新的最新版本(本安装跟踪 `^0.2.2-rc.1`,当前解析为 `0.2.2-rc.5`)。
168
+ 2. 弹窗显示当前版本 → 新版本及 GitHub 更新说明;检测到仍在运行的对话或后台任务时给出风险提示,可选择立即更新或按设置推迟(默认 60 分钟)。确认后进入进度弹窗(阶段、百分比、已用时、npm 活动日志),并可最小化为悬浮胶囊;后台发现新版本会提示,已是最新版本则保持静默。
163
169
  3. 把新版本安装到安装根目录的**副本**中,校验版本后原子切换;切换前运行中的文件不受影响。
164
170
  4. 成功后自动退出服务并关闭窗口,用桌面快捷方式重新启动即为新版本。
165
171
 
@@ -176,7 +182,11 @@ MIT © 2026 Tianrun Gu. See [LICENSE](LICENSE).
176
182
  - Tooltip:状态、版本、地址、运行时长、可更新版本与更新进度;
177
183
  - 左键:打开/聚焦 Web 界面(服务未运行时先启动);
178
184
  - 右键菜单:**打开**、**打开插件管理**、**插件设置**、**检查更新 / 更新到 vX**、**重启服务**、**停止服务**(打开中的页面会自行关闭窗口)、**打开日志**、**复制访问地址**、**退出托盘**;
179
- - 通知:更新可用/完成、服务停止、启动失败;后台每 30 分钟检查一次,已是最新版本时不弹通知;
185
+ - 通知:更新可用/完成、服务停止、启动失败;启动时和之后每 30 分钟在后台检查,发现新版本只提醒一次,已是最新版本或自动检查失败时不弹通知;
186
+ - 单实例:启动前扫描 `/proc` 中其他 `dsh-tray.py`,已有实例则退出,不再出现两个图标;
187
+ - 图标:默认 DeepSeek 鲸鱼(按主题着色),也可选经典电源图标或自定义 PNG;
188
+ - 同窗导航:菜单“打开插件管理/插件设置”通过 `open-view` 让现有窗口切页,不再新开窗口;
189
+ - 重启时会先等待旧服务释放端口,再启动新服务,避免正常退出过程中出现服务没有真正重启的情况;
180
190
  - 托盘菜单随 DSH 明暗主题切换(读取 `ui-theme` 偏好并结合系统调色板),主题变化时重建图标;
181
191
  - 登录时如果 Plasma 面板/系统托盘尚未就绪,会等待并自动把图标固定到面板显示项,不会被 KDE 收进折叠区。
182
192
  - 托盘通过 `~/.local/state/dsh-app-controls/control.sock`(权限 0600)与宿主通信,不保存浏览器 token/cookie。
@@ -187,11 +197,13 @@ MIT © 2026 Tianrun Gu. See [LICENSE](LICENSE).
187
197
 
188
198
  打开 **插件 → DeepSeek Harness 应用控制**,使用详情底部的设置区(托盘菜单的 **插件设置** 也会打开这里):
189
199
 
190
- - **系统托盘图标**:启用/停用托盘 helper 及登录自启;
200
+ - **系统托盘**:启用/停用托盘 helper 及登录自启;
201
+ - **托盘图标**:DeepSeek、经典电源、或自定义 PNG 路径;
191
202
  - **按钮显示**:检查更新按钮、退出按钮、对话标题栏入口、主界面右上角入口;
192
- - **默认启动窗口大小**:宽度/高度、**记住当前窗口大小**、**恢复自动**;下次打开窗口时生效。
203
+ - **默认启动窗口大小**:宽度/高度、**记住当前窗口大小**、**恢复自动**;下次打开窗口时生效;
204
+ - **更新设置**:后台自动检查(30 分钟)与默认推迟时长(5 分钟到 7 天)。
193
205
 
194
- 设置保存在 `~/.local/state/dsh-app-controls/settings.json`,由宿主、托盘和启动器共享。托盘开关与窗口大小在下次启动 DSH / 打开窗口时生效,按钮显示/隐藏立即生效。启动器使用独立的 Chrome 配置目录(`~/.local/share/dsh-web-chrome`),确保保存的 `--window-size` 可靠生效;DSH 鉴权仍通过启动令牌完成。
206
+ 设置保存在 `~/.local/state/dsh-app-controls/settings.json`,由宿主、托盘和启动器共享。托盘开关与托盘图标立即生效;默认窗口大小在下次打开窗口时生效,按钮显示/隐藏立即生效。启动器使用独立的 Chrome 配置目录(`~/.local/share/dsh-web-chrome`),确保保存的 `--window-size` 可靠生效;DSH 鉴权仍通过启动令牌完成。
195
207
 
196
208
  ### 缓存清理
197
209
 
Binary file
package/lib/client.js CHANGED
@@ -22,15 +22,18 @@ window.__ModuleLoader__.load({
22
22
  const SLOT = 'conversation.session.header.utilities'
23
23
  const STATUS_ENDPOINT = 'api/dsh-app-controls/update'
24
24
  const START_ENDPOINT = 'api/dsh-app-controls/update'
25
+ const DEFER_ENDPOINT = 'api/dsh-app-controls/update/defer'
25
26
  const PROGRESS_ENDPOINT = 'api/dsh-app-controls/update-progress'
26
27
  const STATE_ENDPOINT = 'api/dsh-app-controls/state'
27
28
  const SETTINGS_ENDPOINT = 'api/dsh-app-controls/settings'
28
29
  const CACHE_ENDPOINT = 'api/dsh-app-controls/cache'
29
30
  const CACHE_CLEAN_ENDPOINT = 'api/dsh-app-controls/cache/clean'
31
+ const VIEW_HANDLED_ENDPOINT = 'api/dsh-app-controls/view-handled'
30
32
  const QUIT_ENDPOINT = 'api/dsh-app-controls/quit'
31
33
  const STYLE_ID = 'dsh-app-controls-style'
32
34
  const MODAL_ID = 'dsh-app-controls-modal'
33
35
  const EXIT_ID = 'dsh-app-controls-exit'
36
+ const MINI_ID = 'dsh-app-controls-update-mini'
34
37
  const CLOSE_HINT_ID = 'dsh-app-controls-close-hint'
35
38
  const POLL_INTERVAL_MS = 800
36
39
 
@@ -39,6 +42,9 @@ window.__ModuleLoader__.load({
39
42
  let modalOnClose = null
40
43
  let pollTimer = 0
41
44
  let statePollTimer = 0
45
+ let handledViewId = ''
46
+ let updateToast = null
47
+ let notifiedUpdateVersion = ''
42
48
 
43
49
  // ── small helpers ────────────────────────────────────────────────────────
44
50
  function apiUrl(relative) {
@@ -99,6 +105,8 @@ window.__ModuleLoader__.load({
99
105
  mainOverlay: true,
100
106
  },
101
107
  window: { width: 1400, height: 900 },
108
+ trayIcon: { style: 'deepseek', customPath: '' },
109
+ update: { autoCheck: true, deferMinutes: 60 },
102
110
  }
103
111
  const SETTINGS_TEXT = {
104
112
  zh: {
@@ -108,6 +116,18 @@ window.__ModuleLoader__.load({
108
116
  buttons: '按钮显示',
109
117
  window: '默认启动窗口大小',
110
118
  trayEnabled: '系统托盘图标',
119
+ trayIcon: '托盘图标样式',
120
+ iconStyle: '图标',
121
+ iconDeepseek: 'DeepSeek 鲸鱼(默认)',
122
+ iconClassic: '经典电源图标',
123
+ iconCustom: '自定义图片',
124
+ customPath: '自定义图标路径(PNG/SVG)',
125
+ customPathNote: '填写本机绝对路径;读取失败会自动回退到 DeepSeek 图标。',
126
+ updateSection: '更新设置',
127
+ autoCheck: '后台自动检查更新',
128
+ autoCheckNote: '每 30 分钟静默检查;发现新版本时在界面/托盘提示,已是最新时不打扰。',
129
+ deferMinutes: '推迟更新的默认时长(分钟)',
130
+ deferMinutesNote: '范围 5 到 10080 分钟;托盘和界面共用。',
111
131
  updateButton: '检查并更新按钮',
112
132
  quitButton: '退出服务按钮',
113
133
  headerControls: '对话标题栏入口',
@@ -155,6 +175,18 @@ window.__ModuleLoader__.load({
155
175
  buttons: 'Button visibility',
156
176
  window: 'Default window size',
157
177
  trayEnabled: 'System tray icon',
178
+ trayIcon: 'Tray icon style',
179
+ iconStyle: 'Icon',
180
+ iconDeepseek: 'DeepSeek whale (default)',
181
+ iconClassic: 'Classic power icon',
182
+ iconCustom: 'Custom image',
183
+ customPath: 'Custom icon path (PNG/SVG)',
184
+ customPathNote: 'Absolute local path; falls back to the DeepSeek icon if it cannot be read.',
185
+ updateSection: 'Update settings',
186
+ autoCheck: 'Check for updates in the background',
187
+ autoCheckNote: 'Silent check every 30 minutes; notify only when a new version exists.',
188
+ deferMinutes: 'Default defer duration (minutes)',
189
+ deferMinutesNote: '5 to 10080 minutes; shared by the tray and the Web UI.',
158
190
  updateButton: 'Check/update button',
159
191
  quitButton: 'Quit button',
160
192
  headerControls: 'Conversation header entry',
@@ -220,6 +252,8 @@ window.__ModuleLoader__.load({
220
252
  const source = input !== null && typeof input === 'object' ? input : {}
221
253
  const features = source.features !== null && typeof source.features === 'object' ? source.features : {}
222
254
  const windowSize = source.window !== null && typeof source.window === 'object' ? source.window : {}
255
+ const trayIcon = source.trayIcon !== null && typeof source.trayIcon === 'object' ? source.trayIcon : {}
256
+ const update = source.update !== null && typeof source.update === 'object' ? source.update : {}
223
257
  const boolean = (value, fallback) => (typeof value === 'boolean' ? value : fallback)
224
258
  const size = (value) => {
225
259
  const number = typeof value === 'number' ? value : Number(value)
@@ -242,6 +276,16 @@ window.__ModuleLoader__.load({
242
276
  mainOverlay: boolean(features.mainOverlay, DEFAULT_SETTINGS.features.mainOverlay),
243
277
  },
244
278
  window: { width, height },
279
+ trayIcon: {
280
+ style: ['deepseek', 'classic', 'custom'].includes(trayIcon.style) ? trayIcon.style : DEFAULT_SETTINGS.trayIcon.style,
281
+ customPath: typeof trayIcon.customPath === 'string' ? trayIcon.customPath.trim().slice(0, 1024) : '',
282
+ },
283
+ update: {
284
+ autoCheck: boolean(update.autoCheck, DEFAULT_SETTINGS.update.autoCheck),
285
+ deferMinutes: Number.isFinite(Number(update.deferMinutes))
286
+ ? Math.min(7 * 24 * 60, Math.max(5, Math.round(Number(update.deferMinutes))))
287
+ : DEFAULT_SETTINGS.update.deferMinutes,
288
+ },
245
289
  }
246
290
  }
247
291
 
@@ -417,6 +461,8 @@ window.__ModuleLoader__.load({
417
461
  ...partial,
418
462
  features: { ...draft.features, ...(partial.features ?? {}) },
419
463
  window: { ...draft.window, ...(partial.window ?? {}) },
464
+ trayIcon: { ...draft.trayIcon, ...(partial.trayIcon ?? {}) },
465
+ update: { ...draft.update, ...(partial.update ?? {}) },
420
466
  })
421
467
  void commit(next)
422
468
  }
@@ -427,6 +473,8 @@ window.__ModuleLoader__.load({
427
473
  ...partial,
428
474
  features: { ...draft.features, ...(partial.features ?? {}) },
429
475
  window: { ...draft.window, ...(partial.window ?? {}) },
476
+ trayIcon: { ...draft.trayIcon, ...(partial.trayIcon ?? {}) },
477
+ update: { ...draft.update, ...(partial.update ?? {}) },
430
478
  }))
431
479
  }
432
480
 
@@ -479,6 +527,75 @@ window.__ModuleLoader__.load({
479
527
  }),
480
528
  ),
481
529
  ),
530
+ h(
531
+ 'div',
532
+ { className: 'dsh-ac-settings-group' },
533
+ h('div', { className: 'dsh-ac-settings-group-title' }, translate('trayIcon')),
534
+ h(
535
+ 'label',
536
+ { className: 'dsh-ac-settings-row' },
537
+ h('span', null, translate('iconStyle')),
538
+ h(
539
+ 'select',
540
+ {
541
+ value: draft.trayIcon.style,
542
+ disabled: saving,
543
+ onChange: (event) => patch({ trayIcon: { style: event.target.value } }),
544
+ },
545
+ h('option', { value: 'deepseek' }, translate('iconDeepseek')),
546
+ h('option', { value: 'classic' }, translate('iconClassic')),
547
+ h('option', { value: 'custom' }, translate('iconCustom')),
548
+ ),
549
+ ),
550
+ draft.trayIcon.style === 'custom'
551
+ ? h(
552
+ 'div',
553
+ { className: 'dsh-ac-settings-field' },
554
+ h('label', null, translate('customPath')),
555
+ h('input', {
556
+ type: 'text',
557
+ value: draft.trayIcon.customPath,
558
+ placeholder: '/home/me/Pictures/icon.png',
559
+ disabled: saving,
560
+ onChange: (event) => editDraft({ trayIcon: { customPath: event.target.value } }),
561
+ onBlur: () => patch({ trayIcon: { customPath: draft.trayIcon.customPath } }),
562
+ }),
563
+ h('p', { className: 'dsh-ac-settings-note' }, translate('customPathNote')),
564
+ )
565
+ : null,
566
+ ),
567
+ h(
568
+ 'div',
569
+ { className: 'dsh-ac-settings-group' },
570
+ h('div', { className: 'dsh-ac-settings-group-title' }, translate('updateSection')),
571
+ h(
572
+ 'label',
573
+ { className: 'dsh-ac-settings-row' },
574
+ h('span', null, translate('autoCheck')),
575
+ h('input', {
576
+ type: 'checkbox',
577
+ checked: draft.update.autoCheck,
578
+ disabled: saving,
579
+ onChange: (event) => patch({ update: { autoCheck: event.target.checked } }),
580
+ }),
581
+ ),
582
+ h('p', { className: 'dsh-ac-settings-note' }, translate('autoCheckNote')),
583
+ h(
584
+ 'div',
585
+ { className: 'dsh-ac-settings-field' },
586
+ h('label', null, translate('deferMinutes')),
587
+ h('input', {
588
+ type: 'number',
589
+ min: 5,
590
+ max: 10080,
591
+ value: String(draft.update.deferMinutes),
592
+ disabled: saving,
593
+ onChange: (event) => editDraft({ update: { deferMinutes: Number(event.target.value) } }),
594
+ onBlur: () => patch({ update: { deferMinutes: draft.update.deferMinutes } }),
595
+ }),
596
+ h('p', { className: 'dsh-ac-settings-note' }, translate('deferMinutesNote')),
597
+ ),
598
+ ),
482
599
  h(
483
600
  'div',
484
601
  { className: 'dsh-ac-settings-group' },
@@ -667,6 +784,10 @@ window.__ModuleLoader__.load({
667
784
  '.dsh-ac-settings-size button{height:30px;padding:0 12px;border:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.3));border-radius:6px;background:var(--dsw-alias-bg-l1,transparent);color:var(--dsw-alias-label-primary,inherit);font:inherit;font-size:12px;cursor:pointer}',
668
785
  '.dsh-ac-settings-size button:hover{background:var(--dsw-alias-bg-l2,rgba(127,127,127,.12))}',
669
786
  '.dsh-ac-settings-size button:disabled{opacity:.55;cursor:default}',
787
+ '.dsh-ac-settings-field{display:flex;flex-direction:column;gap:5px;font-size:13px;color:var(--dsw-alias-label-secondary,inherit)}',
788
+ '.dsh-ac-settings-field input,.dsh-ac-settings-field select{height:30px;box-sizing:border-box;padding:0 8px;border:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.3));border-radius:6px;background:var(--dsw-alias-bg-l1,transparent);color:var(--dsw-alias-label-primary,inherit);font:inherit}',
789
+ '.dsh-ac-settings-field input:focus,.dsh-ac-settings-field select:focus{outline:2px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary,#4d6bfe));outline-offset:1px}',
790
+ '.dsh-ac-settings-field input[type="number"]{width:120px}',
670
791
  '.dsh-ac-settings-note{margin:0;font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary,inherit);opacity:.8}',
671
792
  '.dsh-ac-cache-group{gap:6px}',
672
793
  '.dsh-ac-cache-summary{font-size:12px;color:var(--dsw-alias-label-tertiary,inherit)}',
@@ -720,6 +841,16 @@ window.__ModuleLoader__.load({
720
841
  '@keyframes dsh-ac-pop{from{opacity:0;transform:translateY(6px) scale(.98)}to{opacity:1;transform:none}}',
721
842
  '@keyframes dsh-ac-spin{to{transform:rotate(360deg)}}',
722
843
  '@keyframes dsh-ac-shimmer{0%{transform:translateX(-100%)}60%,100%{transform:translateX(180%)}}',
844
+ '.dsh-ac-progress-min{position:fixed;right:24px;bottom:24px;z-index:2147483000;display:inline-flex;align-items:center;gap:10px;padding:10px 13px;border:1px solid rgba(127,127,127,.34);border-radius:12px;background:#ffffff;color:#1b1f24;box-shadow:0 10px 34px rgba(0,0,0,.28);font:13px/1.4 system-ui,-apple-system,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;cursor:pointer}',
845
+ 'body[data-ds-dark-theme] .dsh-ac-progress-min{background:#20242c;color:#e9ebef;box-shadow:0 10px 34px rgba(0,0,0,.52)}',
846
+ '.dsh-ac-progress-min:hover{border-color:rgba(77,107,254,.7)}',
847
+ '.dsh-ac-progress-min-dot{width:8px;height:8px;border-radius:50%;background:#4d6bfe;box-shadow:0 0 0 4px rgba(77,107,254,.14);flex:none}',
848
+ '.dsh-ac-progress-min-text{font-variant-numeric:tabular-nums;white-space:nowrap}',
849
+ '.dsh-ac-update-toast{position:fixed;right:24px;bottom:76px;z-index:2147482900;display:inline-flex;align-items:center;gap:10px;max-width:min(360px,calc(100vw - 48px));box-sizing:border-box;padding:10px 12px;border:1px solid rgba(127,127,127,.34);border-radius:12px;background:#ffffff;color:#1b1f24;box-shadow:0 10px 34px rgba(0,0,0,.28);font:13px/1.4 system-ui,-apple-system,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif}',
850
+ 'body[data-ds-dark-theme] .dsh-ac-update-toast{background:#20242c;color:#e9ebef;box-shadow:0 10px 34px rgba(0,0,0,.52)}',
851
+ '.dsh-ac-update-toast button{appearance:none;border:1px solid rgba(127,127,127,.42);border-radius:7px;padding:4px 10px;background:transparent;color:inherit;font:inherit;cursor:pointer;flex:none}',
852
+ '.dsh-ac-update-toast button:hover{background:rgba(127,127,127,.14)}',
853
+ '.dsh-ac-update-toast .dsh-ac-update-toast-close{border:0;padding:0 2px;font-size:17px;line-height:1;opacity:.7}',
723
854
  '@media (prefers-reduced-motion: reduce){.dsh-ac-backdrop,.dsh-ac-dialog,.dsh-ac-exit,.dsh-ac-fill::after,.dsh-ac-spinner{animation:none}}',
724
855
  ].join('\n')
725
856
  document.head.appendChild(style)
@@ -736,6 +867,8 @@ window.__ModuleLoader__.load({
736
867
  function removeModal() {
737
868
  const existing = document.getElementById(MODAL_ID)
738
869
  if (existing !== null) existing.remove()
870
+ const mini = document.getElementById(MINI_ID)
871
+ if (mini !== null) mini.remove()
739
872
  document.removeEventListener('keydown', onModalKey)
740
873
  activeModal = null
741
874
  modalDismissible = false
@@ -861,16 +994,60 @@ window.__ModuleLoader__.load({
861
994
  const elapsed = document.createElement('div')
862
995
  elapsed.className = 'dsh-ac-elapsed'
863
996
  wrap.appendChild(elapsed)
864
- openModal({ title: '正在更新 DeepSeek Harness', content: wrap, dismissible: false })
997
+
998
+ let modal = null
999
+ let miniText = null
1000
+ function minimize() {
1001
+ if (modal === null) return
1002
+ modal.backdrop.style.display = 'none'
1003
+ const mini = document.getElementById(MINI_ID)
1004
+ if (mini !== null) mini.style.display = 'inline-flex'
1005
+ }
1006
+ function restore() {
1007
+ if (modal === null) return
1008
+ modal.backdrop.style.display = ''
1009
+ const mini = document.getElementById(MINI_ID)
1010
+ if (mini !== null) mini.style.display = 'none'
1011
+ }
1012
+
1013
+ modal = openModal({
1014
+ title: '正在更新 DeepSeek Harness',
1015
+ content: wrap,
1016
+ dismissible: false,
1017
+ buttons: [{ label: '最小化', variant: 'secondary', onClick: minimize }],
1018
+ })
1019
+
1020
+ // A compact floating progress pill keeps the page usable while the
1021
+ // update continues. Click it to bring the full dialog back.
1022
+ const mini = document.createElement('button')
1023
+ mini.type = 'button'
1024
+ mini.id = MINI_ID
1025
+ mini.className = 'dsh-ac-progress-min'
1026
+ mini.setAttribute('aria-label', '展开更新进度')
1027
+ mini.title = '展开更新进度'
1028
+ const dot = document.createElement('span')
1029
+ dot.className = 'dsh-ac-progress-min-dot'
1030
+ miniText = document.createElement('span')
1031
+ miniText.className = 'dsh-ac-progress-min-text'
1032
+ miniText.textContent = '更新中 0%'
1033
+ mini.appendChild(dot)
1034
+ mini.appendChild(miniText)
1035
+ mini.addEventListener('click', restore)
1036
+ mini.style.display = 'none'
1037
+ document.body.appendChild(mini)
1038
+
865
1039
  return {
866
1040
  update(state) {
867
1041
  const value = Math.max(0, Math.min(100, Math.round(state.percent ?? 0)))
868
- fill.style.width = `${value}%`
869
- percent.textContent = `${value}%`
870
- phase.textContent = state.message || '正在更新…'
871
- activity.textContent = state.activity ? state.activity : ''
872
- elapsed.textContent = state.elapsedMs > 0 ? `已用时 ${formatDuration(state.elapsedMs)}` : ''
1042
+ if (fill.isConnected) fill.style.width = `${value}%`
1043
+ if (percent.isConnected) percent.textContent = `${value}%`
1044
+ if (phase.isConnected) phase.textContent = state.message || '正在更新…'
1045
+ if (activity.isConnected) activity.textContent = state.activity ? state.activity : ''
1046
+ if (elapsed.isConnected) elapsed.textContent = state.elapsedMs > 0 ? `已用时 ${formatDuration(state.elapsedMs)}` : ''
1047
+ if (miniText !== null && miniText.isConnected) miniText.textContent = `更新中 ${value}%`
873
1048
  },
1049
+ minimize,
1050
+ restore,
874
1051
  }
875
1052
  }
876
1053
 
@@ -937,6 +1114,83 @@ window.__ModuleLoader__.load({
937
1114
  }
938
1115
  }
939
1116
 
1117
+ function dismissUpdateToast() {
1118
+ if (updateToast !== null && updateToast.parentNode !== null) updateToast.parentNode.removeChild(updateToast)
1119
+ updateToast = null
1120
+ }
1121
+
1122
+ function showUpdateToast(status) {
1123
+ if (typeof document === 'undefined' || status === null || typeof status !== 'object') return
1124
+ const version = String(status.candidate ?? '')
1125
+ if (version === '') return
1126
+ notifiedUpdateVersion = version
1127
+ try {
1128
+ if (window.localStorage.getItem(`dsh-ac-update-notified:${version}`) === '1') return
1129
+ window.localStorage.setItem(`dsh-ac-update-notified:${version}`, '1')
1130
+ } catch {
1131
+ // private mode: still show once per page
1132
+ }
1133
+ dismissUpdateToast()
1134
+ const toast = document.createElement('div')
1135
+ toast.className = 'dsh-ac-update-toast'
1136
+ toast.setAttribute('role', 'status')
1137
+ const text = document.createElement('span')
1138
+ text.textContent = `发现新版本 ${version}`
1139
+ const action = document.createElement('button')
1140
+ action.type = 'button'
1141
+ action.textContent = '查看'
1142
+ action.addEventListener('click', () => {
1143
+ dismissUpdateToast()
1144
+ openConfirmUpdate(status, null)
1145
+ })
1146
+ const close = document.createElement('button')
1147
+ close.type = 'button'
1148
+ close.className = 'dsh-ac-update-toast-close'
1149
+ close.setAttribute('aria-label', '关闭')
1150
+ close.textContent = '×'
1151
+ close.addEventListener('click', dismissUpdateToast)
1152
+ toast.appendChild(text)
1153
+ toast.appendChild(action)
1154
+ toast.appendChild(close)
1155
+ document.body.appendChild(toast)
1156
+ updateToast = toast
1157
+ }
1158
+
1159
+ function pluginsViewVisible() {
1160
+ const text = document.body.innerText || ''
1161
+ return text.includes('安装、启用和配置插件') || text.includes('Install, enable and configure')
1162
+ }
1163
+
1164
+ function navigateToView(view) {
1165
+ if (view === 'plugins') {
1166
+ const clicked = clickPluginsNav()
1167
+ if (clicked) {
1168
+ // A freshly created session can still finish routing after the first
1169
+ // click; re-apply the navigation if the Plugins page did not stick.
1170
+ window.setTimeout(() => { if (!pluginsViewVisible()) clickPluginsNav() }, 700)
1171
+ window.setTimeout(() => { if (!pluginsViewVisible()) clickPluginsNav() }, 1500)
1172
+ }
1173
+ return clicked
1174
+ }
1175
+ if (view === 'settings') {
1176
+ if (openSettingsNavigation()) return true
1177
+ if (clickPluginsNav()) {
1178
+ window.setTimeout(clickBundleCard, 600)
1179
+ return true
1180
+ }
1181
+ }
1182
+ return false
1183
+ }
1184
+
1185
+ function acknowledgeView(id) {
1186
+ if (typeof fetch !== 'function') return
1187
+ void fetch(apiUrl(VIEW_HANDLED_ENDPOINT), {
1188
+ method: 'POST',
1189
+ headers: { 'content-type': 'application/json' },
1190
+ body: JSON.stringify({ id }),
1191
+ }).catch(() => {})
1192
+ }
1193
+
940
1194
  // Tray-initiated quit/update requests set `quitRequested` on the host; the
941
1195
  // page notices it here and closes the window after the service stops.
942
1196
  function stopStatePolling() {
@@ -955,6 +1209,20 @@ window.__ModuleLoader__.load({
955
1209
  cache: 'no-store',
956
1210
  })
957
1211
  const data = await readJson(response)
1212
+ if (response.ok && data !== null) {
1213
+ const pending = data.pendingView
1214
+ if (pending !== null && typeof pending === 'object' && typeof pending.id === 'string' && pending.id !== handledViewId) {
1215
+ if (navigateToView(pending.view)) {
1216
+ handledViewId = pending.id
1217
+ acknowledgeView(pending.id)
1218
+ }
1219
+ }
1220
+ const update = data.update
1221
+ const deferred = typeof data.updateDeferUntil === 'number' && data.updateDeferUntil > Date.now()
1222
+ if (update !== null && typeof update === 'object' && update.updateAvailable === true && !deferred) {
1223
+ showUpdateToast(update)
1224
+ }
1225
+ }
958
1226
  if (response.ok && data !== null && data.quitRequested === true) {
959
1227
  if (document.getElementById(EXIT_ID) === null) {
960
1228
  showExitScreen({
@@ -1185,29 +1453,85 @@ window.__ModuleLoader__.load({
1185
1453
  }
1186
1454
  }
1187
1455
 
1456
+ function activityWarning(activity) {
1457
+ if (activity === null || typeof activity !== 'object' || activity.available === false) {
1458
+ return '暂时无法确认是否有任务在运行,更新前请留意。'
1459
+ }
1460
+ if (activity.active !== true) {
1461
+ return '当前没有检测到正在运行的任务。'
1462
+ }
1463
+ const parts = []
1464
+ if (activity.turns > 0) parts.push(`${activity.turns} 个进行中的对话`)
1465
+ if (activity.jobs > 0) parts.push(`${activity.jobs} 个后台任务`)
1466
+ return `检测到 ${activity.count} 个正在运行的任务(${parts.join('、')})。更新会重启本地服务,这些任务会被中断。`
1467
+ }
1468
+
1469
+ function deferLabel(minutes) {
1470
+ return minutes === 60 ? '1 小时' : `${minutes} 分钟`
1471
+ }
1472
+
1473
+ async function deferUpdate(button) {
1474
+ closeModal()
1475
+ resetUpdateButton(button)
1476
+ const minutes = clientSettings.update.deferMinutes
1477
+ try {
1478
+ const response = await fetch(apiUrl(DEFER_ENDPOINT), {
1479
+ method: 'POST',
1480
+ headers: { 'content-type': 'application/json' },
1481
+ body: JSON.stringify({ minutes }),
1482
+ })
1483
+ const body = await readJson(response)
1484
+ if (!response.ok || body === null || body.ok !== true) throw new Error(failureText(body, response.status))
1485
+ if (notifiedUpdateVersion !== '') {
1486
+ try {
1487
+ window.localStorage.removeItem(`dsh-ac-update-notified:${notifiedUpdateVersion}`)
1488
+ } catch {
1489
+ // private mode: no stored marker
1490
+ }
1491
+ }
1492
+ openInfo('已推迟更新', `已推迟 ${deferLabel(minutes)}。后台再次检测到新版本时会再提醒你,也可以随时手动更新。`)
1493
+ } catch (error) {
1494
+ openError(`推迟更新失败:${errorMessage(error)}`)
1495
+ }
1496
+ }
1497
+
1498
+ function releaseNotesText(status) {
1499
+ const notes = status.releaseNotes
1500
+ if (notes === null || typeof notes !== 'object' || typeof notes.notes !== 'string') return ''
1501
+ const text = notes.notes.trim()
1502
+ if (text === '') return ''
1503
+ const title = typeof notes.title === 'string' && notes.title.trim() !== '' ? notes.title.trim() : status.candidate
1504
+ return `\n\n更新说明(${title}):\n${text.slice(0, 1600)}`
1505
+ }
1506
+
1188
1507
  function openConfirmUpdate(status, button) {
1189
1508
  const channelNote = status.channel === 'next' ? '(预发布版本)' : ''
1190
1509
  const finish = () => {
1191
1510
  closeModal()
1192
1511
  resetUpdateButton(button)
1193
1512
  }
1513
+ const risky = status.activity !== null && typeof status.activity === 'object' && status.activity.active === true
1194
1514
  openModal({
1195
1515
  title: '发现新版本',
1196
1516
  message:
1197
1517
  `当前版本:${status.current}\n` +
1198
1518
  `新版本:${status.candidate}${channelNote}\n\n` +
1199
- '更新会在后台下载并安装,通常需要几分钟;期间不能结束服务,完成后会自动退出并关闭窗口。',
1519
+ `${activityWarning(status.activity)}\n\n` +
1520
+ '更新会在后台下载并安装,通常需要几分钟;完成后服务会自动退出并关闭窗口。' +
1521
+ releaseNotesText(status),
1200
1522
  dismissible: true,
1201
1523
  onClose: finish,
1202
1524
  buttons: [
1203
1525
  { label: '取消', variant: 'secondary', onClick: finish },
1204
- { label: '立即更新', variant: 'primary', onClick: () => startUpdate(status, button) },
1526
+ { label: `推迟 ${deferLabel(clientSettings.update.deferMinutes)}`, variant: risky ? 'primary' : 'secondary', onClick: () => deferUpdate(button) },
1527
+ { label: '立即更新', variant: 'secondary', onClick: () => startUpdate(status, button) },
1205
1528
  ],
1206
1529
  })
1207
1530
  }
1208
1531
 
1209
1532
  async function startUpdate(status, button) {
1210
1533
  closeModal()
1534
+ if (button && button.isConnected) button.disabled = true
1211
1535
  const progress = openProgress(status.current, status.candidate)
1212
1536
  progress.update({ percent: 0, message: '正在准备更新…', elapsedMs: 0 })
1213
1537
  try {