@laraveladmin/dsh-stay-awake 0.2.14 → 0.3.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/CHANGELOG.md +52 -0
- package/README.en.md +35 -11
- package/README.md +35 -11
- package/client.js +242 -20
- package/docs/REQUIREMENTS.md +35 -11
- package/docs/VERIFICATION.md +57 -0
- package/index.js +107 -1
- package/lib/auto-resume.js +95 -0
- package/lib/config.js +35 -0
- package/lib/probe.js +50 -0
- package/lib/resume.js +173 -0
- package/lib/server.js +22 -8
- package/lib/sound.js +19 -4
- package/lib/state.js +2 -1
- package/locale/en.json +1 -1
- package/locale/zh-Hant.json +6 -0
- package/locale/zh.json +1 -1
- package/market/index.json +2 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,57 @@
|
|
|
1
1
|
# 变更记录 · Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.1 — 2026-12-03
|
|
4
|
+
|
|
5
|
+
### 修复
|
|
6
|
+
|
|
7
|
+
- 窗口缩小后弹层位置偶尔不对:CSS anchor positioning 只把弹层「绑」在触发点上,并不保证它落在视口内——
|
|
8
|
+
`left` 锚定触发点会让宽面板溢出右边缘,`@position-try` 回退又只改纵向。现在改为**测量后定位**:
|
|
9
|
+
打开时、窗口 resize、composer 滚动、弹层自身尺寸变化(状态行、语言切换、提示)都会重新计算,
|
|
10
|
+
取「优先在触发点上方、放不下就放下方」,左右按视口 12px 边距夹紧;触发点被窄屏布局隐藏或滚出视口时
|
|
11
|
+
回退到输入框上方居中;高度超过视口时改为内部滚动。
|
|
12
|
+
- 定位完成前弹层 `visibility:hidden`,避免先画在错误位置再跳一下。
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## 0.3.0 — 2026-12-03
|
|
16
|
+
|
|
17
|
+
### 新功能:断网自动重试
|
|
18
|
+
|
|
19
|
+
- 合盖休眠导致正在跑的一轮断网失败后,网络恢复时**自动按下 DSH 的「重试」**:调用宿主
|
|
20
|
+
`sessionController.prompt` 发送空内容(`retry` 来源)消息重跑失败的那一步,不往对话里插文字、
|
|
21
|
+
不重放已完成的工具调用。
|
|
22
|
+
- 触发判定与 DSH 自己的可续跑语义一致:本轮有被接纳的人类输入、有一次失败的模型请求、以网络类错误
|
|
23
|
+
(默认 `TRANSPORT` / `TIMEOUT`)结束;用户中断、等待审批、限流/服务端错误不触发。
|
|
24
|
+
- 重试前用 **TCP 探测**(默认 `api.deepseek.com:443`,只建连不发数据)确认网络真的恢复;
|
|
25
|
+
宿主休眠时定时器暂停,唤醒后 Wi-Fi 未连通就继续等。
|
|
26
|
+
- 预算:每会话每次故障最多 3 次、60 分钟内有效;用户自己发消息或该轮成功完成会重置;子代理会话不处理。
|
|
27
|
+
- 弹层新增「断网自动重试」开关(默认开,持久化到 `state.json`),开关下方实时显示
|
|
28
|
+
「等待网络恢复… / 正在自动重试… / 自动重试未成功」,底部状态行提示「已自动重试」。
|
|
29
|
+
- 宿主协议升到 3;不再假设旧宿主可用:协议不匹配时弹层提示重新加载。
|
|
30
|
+
|
|
31
|
+
### 新功能:需要你回答时响一声
|
|
32
|
+
|
|
33
|
+
- agent 提问(`ask_user_question`)或工具调用等审批时立即响一声——这是唯一「回合还没结束也会响」的
|
|
34
|
+
提示音,否则它在你离开后会一直安静地等。监听宿主 waterfall 事件 `user-questions/request` 与
|
|
35
|
+
`approval/request`,旁路调用 `next()`,不干扰问答本身。
|
|
36
|
+
- 第三种音效:macOS `Ping`、Windows `SystemSounds.Question`、Linux `message.oga`,可自定义
|
|
37
|
+
`questionSound`;受同一个「提示音」总开关约束,1 秒节流防连响。
|
|
38
|
+
|
|
39
|
+
### 界面与多语言
|
|
40
|
+
|
|
41
|
+
- 弹层「完成提示音」改名「提示音」,旁边改为「完成 / 失败 / 提醒」三个小按钮,可分别试听三种音效
|
|
42
|
+
(宿主 `test-sound` 新增 `kind` 参数,未知值 400)。
|
|
43
|
+
- 新增**繁体中文**完整字典:DSH 只内置简体,插件通过 `ctx.locale.addLanguage` 贡献可选语言
|
|
44
|
+
「繁體中文」(id `zh-Hant`,回退 `zh`),并新增 `locale/zh-Hant.json` 供插件管理器显示;三套字典
|
|
45
|
+
各 54 键、键集合一致。
|
|
46
|
+
|
|
47
|
+
### 文档与测试
|
|
48
|
+
|
|
49
|
+
- README 中英新增「断网自动重试」「提示音(含提问提醒)」章节与繁体说明,并更正「不联网」表述:
|
|
50
|
+
唯一外发动作是探测,且可关闭。
|
|
51
|
+
- REQUIREMENTS 新增 FR-12 与 AC-21~24、FR-10.15~17;VERIFICATION 记录本轮验证范围与未验证项。
|
|
52
|
+
- 新增 28 项测试(失败判定状态机、探测、调度器、预算/窗口、开关、提问提醒、试听三音效),单测 81 → 109。
|
|
53
|
+
|
|
54
|
+
|
|
3
55
|
## 0.2.14 — 2026-12-03
|
|
4
56
|
|
|
5
57
|
### 修复
|
package/README.en.md
CHANGED
|
@@ -31,14 +31,27 @@ Most existing plugins equate "a task" with "a session in the running state". DSH
|
|
|
31
31
|
|
|
32
32
|
The rule is a pure function: `wanted = enabled && (agents + maintenance + jobs > 0)`. Exactly one system power assertion is held process-wide.
|
|
33
33
|
|
|
34
|
-
##
|
|
34
|
+
## Sounds
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
Three moments each get one cue, played on the machine that runs the DSH host — they reach you even when the window is minimised.
|
|
37
37
|
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
38
|
+
- **Done**: one chime per work segment (from work starting to everything finishing), including background jobs and multiple sessions. `Glass` by default.
|
|
39
|
+
- **Failed**: the turn ended with an error or an interrupt. `Basso` by default.
|
|
40
|
+
- **Your turn**: the agent asked a question (`ask_user_question`) or a tool call waits for approval — rings immediately. `Ping` by default. This is the only cue that can fire while the turn is still open; without it the agent would wait for you in silence.
|
|
41
|
+
- Segments shorter than 20 seconds stay silent; autonomous goal/scheduled rounds stay silent (questions and approvals still ring).
|
|
42
|
+
- The panel's **Sounds** master switch covers all three; three small buttons (Done / Error / Alert) audition each cue.
|
|
43
|
+
- Sound files, volume, the minimum duration and whether questions ring live in `cordis.patch.yml`.
|
|
44
|
+
|
|
45
|
+
## Retry after reconnect
|
|
46
|
+
|
|
47
|
+
A closed lid drops the connection under a running turn: DSH retries `TRANSPORT` / `TIMEOUT` five times with backoff, then stops and waits for you to press Retry. This feature **presses that button for you once the network is back**.
|
|
48
|
+
|
|
49
|
+
- **Trigger**: a turn ended with a network-class failure (default `TRANSPORT` / `TIMEOUT`) after you had sent input and a model request had actually been attempted. User aborts, approval waits, rate limits and server errors never trigger it.
|
|
50
|
+
- **When it fires**: every 15 seconds the plugin makes a **TCP connection probe** to `api.deepseek.com:443` — handshake only, no request data, no session content read. The retry happens on the first successful probe. Timers are suspended during host sleep, so after a wake it simply keeps waiting until Wi-Fi is really up.
|
|
51
|
+
- **How it retries**: exactly like the Retry button — an **empty `retry` message** re-runs the failed step. No text is injected into the conversation and completed tool calls are not replayed.
|
|
52
|
+
- **Budget**: at most **3** automatic retries per failure, valid for **60 minutes**. A message you send yourself, or a later successful turn, resets the budget. Subagent sessions are left alone (their parent owns the failure).
|
|
53
|
+
- **Off means off**: switching the panel toggle off clears the queue immediately; a host restart does not keep pending retries.
|
|
54
|
+
- **Dependency**: needs DSH's `sessionController` service (present in Desktop and Web). Without it the feature degrades silently — keep-awake and the sound keep working.
|
|
42
55
|
|
|
43
56
|
## Behaviour
|
|
44
57
|
|
|
@@ -157,13 +170,22 @@ Override the row by id in the profile's `cordis.patch.yml`:
|
|
|
157
170
|
reconcileSeconds: 60 # reconciliation interval, 0 = disabled
|
|
158
171
|
maxMaintenanceMinutes: 120 # longest a maintenance bracket may stay open
|
|
159
172
|
caffeinatePath: /usr/bin/caffeinate # macOS only, advanced override
|
|
160
|
-
sound: true #
|
|
173
|
+
sound: true # sounds master switch (panel toggle)
|
|
161
174
|
soundOnError: true # different sound for failures
|
|
162
175
|
soundMinSeconds: 20 # stay silent below this duration, 0 = always
|
|
163
176
|
soundOnlyUserTasks: true # ignore autonomous rounds
|
|
177
|
+
soundOnQuestion: true # ring when a question/approval waits (no separate toggle)
|
|
178
|
+
questionSound: '' # custom "your turn" sound file (absolute path)
|
|
164
179
|
soundVolume: 1 # 0-3, macOS/Linux
|
|
165
180
|
successSound: '' # custom completion file (absolute path)
|
|
166
181
|
errorSound: '' # custom failure file
|
|
182
|
+
autoResume: true # retry after reconnect (panel toggle)
|
|
183
|
+
autoResumeCodes: [TRANSPORT, TIMEOUT] # failure codes that trigger it
|
|
184
|
+
autoResumeProbeHost: api.deepseek.com # probe target (TCP, no data sent)
|
|
185
|
+
autoResumeProbePort: 443
|
|
186
|
+
autoResumeProbeIntervalMs: 15000 # probe interval
|
|
187
|
+
autoResumeWindowMinutes: 60 # how long a failure stays retryable
|
|
188
|
+
autoResumeMaxAttempts: 3 # automatic retries per failure
|
|
167
189
|
```
|
|
168
190
|
|
|
169
191
|
Invalid values fall back to their defaults with a warning; a bad config never blocks loading.
|
|
@@ -185,7 +207,8 @@ Clicking the icon or the "Stay awake" label opens a panel **above the status bar
|
|
|
185
207
|
|---|---|
|
|
186
208
|
| Enabled | Turning it off releases the assertion immediately |
|
|
187
209
|
| Allow display sleep | On = block system sleep only; off = keep the screen on too |
|
|
188
|
-
|
|
|
210
|
+
| Sounds | One cue when a task ends, fails, or needs your answer; three buttons audition each |
|
|
211
|
+
| Retry after reconnect | Retry the turn that failed offline once the network is back (on by default) |
|
|
189
212
|
| Hold for | 30 min / 2 h / cancel, for temporary keeps |
|
|
190
213
|
| Status block | Active sources, scope, backend, hold duration, error reason |
|
|
191
214
|
| Footer | Where advanced options live, source link, version |
|
|
@@ -232,12 +255,13 @@ systemd-inhibit --list
|
|
|
232
255
|
|
|
233
256
|
**Compatibility**: `package.json` declares `engines.dsh: >=0.2.0`, which the plugin market uses for its compatibility badge; older DSH versions are refused.
|
|
234
257
|
|
|
235
|
-
**Local writes**: exactly one state file, `~/.dsh/plugin-data/dsh-stay-awake/state.json` (the
|
|
258
|
+
**Local writes and network**: exactly one state file, `~/.dsh/plugin-data/dsh-stay-awake/state.json` (the panel preferences). It does not modify system power plans, request privileges, read session content, or use the network for update checks. The one outbound action is the **TCP reachability probe** (default `api.deepseek.com:443`, handshake only, no data) while Retry after reconnect is enabled; turning that toggle off stops it.
|
|
236
259
|
|
|
237
260
|
## Internationalization
|
|
238
261
|
|
|
239
|
-
- The
|
|
240
|
-
-
|
|
262
|
+
- The indicator and panel follow the active DSH locale with three complete dictionaries: **Simplified Chinese, Traditional Chinese and English**; other locales fall back to English.
|
|
263
|
+
- DSH ships Simplified Chinese only, so the plugin registers 「繁體中文」 through `ctx.locale.addLanguage` (id `zh-Hant`, falling back to `zh`): plugin copy becomes fully Traditional while the rest of the GUI falls back to Simplified and stays readable.
|
|
264
|
+
- The plugin manager title and description are localized as well (`locale/zh.json`, `locale/zh-Hant.json`, `locale/en.json`).
|
|
241
265
|
- Repository documentation: [简体中文](https://gitee.com/laravel-admin/dsh-stay-awake/blob/main/README.md) / [English](https://gitee.com/laravel-admin/dsh-stay-awake/blob/main/README.en.md).
|
|
242
266
|
|
|
243
267
|
## Development
|
package/README.md
CHANGED
|
@@ -31,14 +31,27 @@ DSH 跑长任务时你离开电脑,系统按空闲策略休眠:进程被挂
|
|
|
31
31
|
|
|
32
32
|
判定为纯函数:`wanted = enabled && (会话 + 维护期 + 后台任务 > 0)`。全局只持有一个系统电源断言。
|
|
33
33
|
|
|
34
|
-
##
|
|
34
|
+
## 提示音
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
三种时机各响一声,不用盯着屏幕——声音在**运行 DSH 的这台机器**上播放,窗口最小化也听得到。
|
|
37
37
|
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
38
|
+
- **完成**:一次「工作段」(从有工作到全部结束)结束时响一次,含后台任务与多会话。默认 `Glass`。
|
|
39
|
+
- **失败**:这一轮以错误/中断结束,默认 `Basso`。
|
|
40
|
+
- **需要你回答**:agent 用 `ask_user_question` 提问、或工具调用等审批时立刻响,默认 `Ping`——这是唯一一个「回合还没结束也响」的情况,否则它会一直安静地等你。
|
|
41
|
+
- 短于 20 秒的任务不响;goal/定时任务等自主轮次不响,避免连响(但提问/审批仍然会提醒你)。
|
|
42
|
+
- 弹层「提示音」总开关控制全部三种;旁边三个小按钮「完成 / 失败 / 提醒」可分别试听。
|
|
43
|
+
- 音效文件、音量、最短时长、是否提醒提问在 `cordis.patch.yml` 配置。
|
|
44
|
+
|
|
45
|
+
## 断网自动重试
|
|
46
|
+
|
|
47
|
+
合盖休眠会让正在跑的那一轮断网失败:DSH 自己会按 `TRANSPORT` / `TIMEOUT` 退避重试 5 次,仍失败就停下等你点「重试」。这个功能在**网络恢复后替你按下那个按钮**。
|
|
48
|
+
|
|
49
|
+
- **触发条件**:某一轮以网络类错误结束(默认 `TRANSPORT` / `TIMEOUT`),且这一轮有你发出的输入、也真的发起过模型请求。用户主动中断、等待审批、限流/服务端错误都不会触发。
|
|
50
|
+
- **生效时机**:每 15 秒对 `api.deepseek.com:443` 做一次 **TCP 连接探测**——只建连,不发任何数据、不读会话内容;通了才重试。宿主休眠时定时器本来就会暂停,唤醒后 Wi-Fi 还没连上就继续等。
|
|
51
|
+
- **重试方式**:等价于界面上的「重试」按钮——发一条**空内容的 retry 消息**重跑失败的那一步,不会往对话里塞文字,也不会重放已完成的工具调用。
|
|
52
|
+
- **上限**:每个会话每次故障最多自动重试 **3 次**、**60 分钟**内有效;你在这期间自己发了消息、或这一轮后来成功完成,计数就重置。子代理会话不处理(由父会话负责)。
|
|
53
|
+
- **关掉即取消**:关闭弹层里的开关会立即清空等待队列;宿主重启后不保留待重试队列。
|
|
54
|
+
- **依赖**:需要 DSH 的 `sessionController` 服务(桌面版与 Web 版都提供);拿不到时功能静默降级,不影响保活与提示音。
|
|
42
55
|
|
|
43
56
|
## 释放与自愈
|
|
44
57
|
|
|
@@ -158,13 +171,22 @@ DSH 默认不带任何索引源。添加本项目随 npm 包发布的索引文
|
|
|
158
171
|
reconcileSeconds: 60 # 对账间隔,0 = 关闭
|
|
159
172
|
maxMaintenanceMinutes: 120 # 维护期括号的最长有效期
|
|
160
173
|
caffeinatePath: /usr/bin/caffeinate # 仅 macOS,高级覆盖
|
|
161
|
-
sound: true #
|
|
174
|
+
sound: true # 提示音总开关(弹层开关)
|
|
162
175
|
soundOnError: true # 失败/中断用不同音效
|
|
163
176
|
soundMinSeconds: 20 # 短于该时长不响,0 = 都响
|
|
164
177
|
soundOnlyUserTasks: true # 只响用户发起的任务,自主轮次不响
|
|
178
|
+
soundOnQuestion: true # 提问/等待审批时提醒(默认开,无独立开关)
|
|
179
|
+
questionSound: '' # 自定义「提醒」音文件(绝对路径)
|
|
165
180
|
soundVolume: 1 # 0~3,macOS/Linux 生效
|
|
166
181
|
successSound: '' # 自定义完成音文件(绝对路径)
|
|
167
182
|
errorSound: '' # 自定义失败音文件
|
|
183
|
+
autoResume: true # 断网自动重试(弹层开关)
|
|
184
|
+
autoResumeCodes: [TRANSPORT, TIMEOUT] # 触发自动重试的失败码
|
|
185
|
+
autoResumeProbeHost: api.deepseek.com # 探测目标(TCP,不发送数据)
|
|
186
|
+
autoResumeProbePort: 443
|
|
187
|
+
autoResumeProbeIntervalMs: 15000 # 探测间隔
|
|
188
|
+
autoResumeWindowMinutes: 60 # 失败后多久内仍然自动重试
|
|
189
|
+
autoResumeMaxAttempts: 3 # 每次故障最多自动重试几次
|
|
168
190
|
```
|
|
169
191
|
|
|
170
192
|
非法值会回落到默认值并记一条 warning,不会导致插件加载失败。
|
|
@@ -186,7 +208,8 @@ DSH 默认不带任何索引源。添加本项目随 npm 包发布的索引文
|
|
|
186
208
|
|---|---|
|
|
187
209
|
| 总开关 | 关掉后立即释放断言,不再自动保持 |
|
|
188
210
|
| 允许屏幕休眠 | 开 = 只防系统休眠;关 = 连屏幕一起保持 |
|
|
189
|
-
|
|
|
211
|
+
| 提示音 | 完成 / 失败 / 需要你回答时各响一声;旁边三个按钮可分别试听 |
|
|
212
|
+
| 断网自动重试 | 网络恢复后自动重试因断网失败的那一轮(默认开) |
|
|
190
213
|
| 临时保持 | 30 分钟 / 2 小时 / 取消,用于临时不想让机器睡 |
|
|
191
214
|
| 状态区 | 活跃源、范围、后端、已持续时长、错误原因 |
|
|
192
215
|
| 底部 | 高级参数在哪改、源码链接、版本号 |
|
|
@@ -235,12 +258,13 @@ systemd-inhibit --list
|
|
|
235
258
|
|
|
236
259
|
**兼容性声明**:`package.json` 声明 `engines.dsh: >=0.2.0`,插件市场据此显示兼容性;低于该版本的 DSH 会被拒绝安装。
|
|
237
260
|
|
|
238
|
-
|
|
261
|
+
**本地写入与网络**:只写一个状态文件 `~/.dsh/plugin-data/dsh-stay-awake/state.json`(弹层里的偏好),不碰系统电源计划、不申请提权、不读取会话内容、不联网检查更新。唯一的外发动作是开启「断网自动重试」后对配置的主机做 **TCP 连接探测**(默认 `api.deepseek.com:443`,只建连、不发送任何数据);关掉该开关即停止。
|
|
239
262
|
|
|
240
263
|
## 多语言
|
|
241
264
|
|
|
242
|
-
-
|
|
243
|
-
-
|
|
265
|
+
- 状态栏指示器与弹层跟随 DSH 当前语言,内置**简体中文、繁體中文、英文**三套完整字典;其余语言回退到英文。
|
|
266
|
+
- DSH 本身只内置简体中文,因此插件通过 `ctx.locale.addLanguage` 注册了「繁體中文」(id `zh-Hant`,回退到 `zh`):选择它之后插件文案是完整繁体,DSH 其余界面回退简体,仍然可读。
|
|
267
|
+
- 插件管理器中的标题与说明同样提供三种语言(`locale/zh.json`、`locale/zh-Hant.json`、`locale/en.json`)。
|
|
244
268
|
- 仓库文档:[简体中文](https://gitee.com/laravel-admin/dsh-stay-awake/blob/main/README.md) / [English](https://gitee.com/laravel-admin/dsh-stay-awake/blob/main/README.en.md)。
|
|
245
269
|
|
|
246
270
|
## 开发
|
package/client.js
CHANGED
|
@@ -22,6 +22,8 @@ window.__ModuleLoader__.load({
|
|
|
22
22
|
const NPM_URL = `https://www.npmjs.com/package/${PACKAGE_NAME}/v/`
|
|
23
23
|
const POLL_MIN_MS = 3000
|
|
24
24
|
const POLL_MAX_MS = 60000
|
|
25
|
+
// Host protocol this client understands: 3 adds the auto-resume switch.
|
|
26
|
+
const PROTOCOL = 3
|
|
25
27
|
// A protection indicator must never claim "holding" while it cannot prove it.
|
|
26
28
|
const UNKNOWN_AFTER_FAILURES = 2
|
|
27
29
|
|
|
@@ -60,10 +62,19 @@ window.__ModuleLoader__.load({
|
|
|
60
62
|
'panel.hold30': '30 分钟',
|
|
61
63
|
'panel.hold120': '2 小时',
|
|
62
64
|
'panel.holdCancel': '取消',
|
|
63
|
-
'panel.sound': '
|
|
65
|
+
'panel.sound': '提示音',
|
|
64
66
|
'panel.testSound': '试听',
|
|
67
|
+
'panel.testSuccess': '完成',
|
|
68
|
+
'panel.testError': '失败',
|
|
69
|
+
'panel.testQuestion': '提醒',
|
|
65
70
|
'panel.testPlayed': '试听已播放',
|
|
66
71
|
'panel.testUnavailable': '试听失败:没有可用的播放器',
|
|
72
|
+
'panel.autoResume': '断网自动重试',
|
|
73
|
+
'panel.autoResumeHint': '网络恢复后自动重试因断网失败的那一轮',
|
|
74
|
+
'panel.resumeWaiting': '等待网络恢复…',
|
|
75
|
+
'panel.resumeRetrying': '正在自动重试…',
|
|
76
|
+
'panel.resumeFailed': '自动重试未成功',
|
|
77
|
+
'panel.resumeRetried': '已自动重试(网络已恢复)',
|
|
67
78
|
'panel.holdDisabled': '总开关关闭时无法临时保持',
|
|
68
79
|
'panel.holdLeft': '剩余',
|
|
69
80
|
'panel.saved': '已保存',
|
|
@@ -109,10 +120,19 @@ window.__ModuleLoader__.load({
|
|
|
109
120
|
'panel.hold30': '30 min',
|
|
110
121
|
'panel.hold120': '2 h',
|
|
111
122
|
'panel.holdCancel': 'Cancel',
|
|
112
|
-
'panel.sound': '
|
|
123
|
+
'panel.sound': 'Sounds',
|
|
113
124
|
'panel.testSound': 'Test',
|
|
125
|
+
'panel.testSuccess': 'Done',
|
|
126
|
+
'panel.testError': 'Error',
|
|
127
|
+
'panel.testQuestion': 'Alert',
|
|
114
128
|
'panel.testPlayed': 'Test sound played',
|
|
115
129
|
'panel.testUnavailable': 'Test failed: no player found',
|
|
130
|
+
'panel.autoResume': 'Retry after reconnect',
|
|
131
|
+
'panel.autoResumeHint': 'Retry the turn that failed offline once the network is back',
|
|
132
|
+
'panel.resumeWaiting': 'Waiting for the network…',
|
|
133
|
+
'panel.resumeRetrying': 'Retrying automatically…',
|
|
134
|
+
'panel.resumeFailed': 'Automatic retry did not go through',
|
|
135
|
+
'panel.resumeRetried': 'Retried after the network came back',
|
|
116
136
|
'panel.holdDisabled': 'Enable the plugin first to hold',
|
|
117
137
|
'panel.holdLeft': 'left',
|
|
118
138
|
'panel.saved': 'Saved',
|
|
@@ -123,20 +143,74 @@ window.__ModuleLoader__.load({
|
|
|
123
143
|
'panel.npm': 'View this version on npm',
|
|
124
144
|
}
|
|
125
145
|
|
|
146
|
+
const ZHT = {
|
|
147
|
+
'brand': '守夜',
|
|
148
|
+
'state.connecting': '連線中',
|
|
149
|
+
'state.idle': '未保持',
|
|
150
|
+
'state.releasing': '釋放中',
|
|
151
|
+
'state.holding': '保持中',
|
|
152
|
+
'state.failed': '異常',
|
|
153
|
+
'state.disabled': '已關閉',
|
|
154
|
+
'state.unknown': '狀態未知',
|
|
155
|
+
'detail.backend': '後端',
|
|
156
|
+
'detail.scope': '範圍',
|
|
157
|
+
'detail.sources': '作用中來源',
|
|
158
|
+
'detail.since': '已持續',
|
|
159
|
+
'detail.error': '原因',
|
|
160
|
+
'sources.agents': '會話',
|
|
161
|
+
'sources.maintenance': '維護',
|
|
162
|
+
'sources.jobs': '背景工作',
|
|
163
|
+
'scope.system': '僅系統',
|
|
164
|
+
'scope.display': '含螢幕',
|
|
165
|
+
'unit.none': '無',
|
|
166
|
+
'hint.unreachable': '無法連線宿主狀態服務,DSH 可能正在重新啟動',
|
|
167
|
+
'error.exited': '電源斷言被意外終止,正在重試',
|
|
168
|
+
'error.backend': '無法啟動電源斷言後端',
|
|
169
|
+
'error.unsupported': '目前平台沒有可用的電源後端',
|
|
170
|
+
'error.unknown': '電源斷言發生未知錯誤',
|
|
171
|
+
'backend.caffeinate': 'macOS 系統喚醒(caffeinate)',
|
|
172
|
+
'backend.setthreadexecutionstate': 'Windows 執行狀態鎖',
|
|
173
|
+
'backend.systemd-inhibit': 'systemd 抑制鎖',
|
|
174
|
+
'panel.enabled': '總開關',
|
|
175
|
+
'panel.allowDisplaySleep': '允許螢幕休眠',
|
|
176
|
+
'panel.allowDisplaySleepHint': '開啟後只防止系統休眠,螢幕依系統設定熄滅',
|
|
177
|
+
'panel.hold': '臨時保持',
|
|
178
|
+
'panel.hold30': '30 分鐘',
|
|
179
|
+
'panel.hold120': '2 小時',
|
|
180
|
+
'panel.holdCancel': '取消',
|
|
181
|
+
'panel.sound': '提示音',
|
|
182
|
+
'panel.testSound': '試聽',
|
|
183
|
+
'panel.testSuccess': '完成',
|
|
184
|
+
'panel.testError': '失敗',
|
|
185
|
+
'panel.testQuestion': '提醒',
|
|
186
|
+
'panel.testPlayed': '試聽已播放',
|
|
187
|
+
'panel.testUnavailable': '試聽失敗:沒有可用的播放程式',
|
|
188
|
+
'panel.autoResume': '斷網自動重試',
|
|
189
|
+
'panel.autoResumeHint': '網路恢復後自動重試因斷網失敗的那一輪',
|
|
190
|
+
'panel.resumeWaiting': '等待網路恢復…',
|
|
191
|
+
'panel.resumeRetrying': '正在自動重試…',
|
|
192
|
+
'panel.resumeFailed': '自動重試未成功',
|
|
193
|
+
'panel.resumeRetried': '已自動重試(網路已恢復)',
|
|
194
|
+
'panel.holdDisabled': '總開關關閉時無法臨時保持',
|
|
195
|
+
'panel.holdLeft': '剩餘',
|
|
196
|
+
'panel.saved': '已儲存',
|
|
197
|
+
'panel.saveFailed': '儲存失敗,請重試',
|
|
198
|
+
'panel.staleHost': '宿主端未載入最新版本:請在外掛頁面停用再啟用「守夜」,或重新啟動 DSH',
|
|
199
|
+
'panel.advanced': '防抖、兜底時長等進階參數在 profile 的 cordis.patch.yml 中設定',
|
|
200
|
+
'panel.repo': '開啟程式碼倉庫',
|
|
201
|
+
'panel.npm': '在 npm 查看此版本',
|
|
202
|
+
}
|
|
203
|
+
|
|
126
204
|
const CSS = `
|
|
127
|
-
.dsa-pill{box-sizing:border-box;border-radius:var(--dsw-radius-sm);max-width:100%;color:var(--dsw-alias-label-tertiary);font:inherit;font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));font-variant-numeric:tabular-nums;white-space:nowrap;background:0 0;border:none;align-items:center;gap:6px;padding:1px 8px;display:inline-flex;cursor:pointer
|
|
205
|
+
.dsa-pill{box-sizing:border-box;border-radius:var(--dsw-radius-sm);max-width:100%;color:var(--dsw-alias-label-tertiary);font:inherit;font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));font-variant-numeric:tabular-nums;white-space:nowrap;background:0 0;border:none;align-items:center;gap:6px;padding:1px 8px;display:inline-flex;cursor:pointer}
|
|
128
206
|
.dsa-pill[aria-expanded="true"]{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}
|
|
129
207
|
@media (hover:hover){.dsa-pill:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary)}}
|
|
130
208
|
.dsa-pill:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px}
|
|
131
209
|
.dsa-pill svg{flex:none;width:14px;height:14px}
|
|
132
210
|
.dsa-label{text-overflow:ellipsis;min-width:0;overflow:hidden}
|
|
133
211
|
.dsa-dot{width:5px;height:5px;border-radius:50%;flex:none}
|
|
134
|
-
.dsa-panel{position:fixed;
|
|
135
|
-
|
|
136
|
-
.dsa-panel{position-anchor:--dsh-stay-awake-panel;top:auto;bottom:max(12px, calc(anchor(top) + 8px));left:max(12px, anchor(left));right:auto;transform:none;height:fit-content;max-height:calc(100dvh - 24px);position-try-fallbacks:--dsa-below, --dsa-wide}
|
|
137
|
-
}
|
|
138
|
-
@position-try --dsa-below{top:max(12px, calc(anchor(bottom) + 8px));bottom:auto}
|
|
139
|
-
@position-try --dsa-wide{left:12px;right:12px;justify-self:stretch}
|
|
212
|
+
.dsa-panel{position:fixed;z-index:1100;box-sizing:border-box;height:fit-content;min-height:0;border:0;border-radius:var(--dsw-radius-lg);background:var(--dsw-specific-menu);backdrop-filter:var(--dsw-menu-backdrop-filter);--dsw-elevation-stroke-color:var(--dsw-alias-border-l1);box-shadow:var(--dsw-elevation-prominent);color:var(--dsw-alias-label-secondary);width:max-content;min-width:min(300px,100vw - 24px);max-width:min(440px,100vw - 24px);max-height:calc(100dvh - 24px);overflow:hidden auto;margin:0;padding:16px;font-size:12px;line-height:18px;cursor:default;pointer-events:auto;text-align:left;visibility:hidden}
|
|
213
|
+
.dsa-panel[data-positioned="true"]{visibility:visible}
|
|
140
214
|
.dsa-head{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:8px;color:var(--dsw-alias-label-primary);font-weight:500}
|
|
141
215
|
.dsa-head-label{display:inline-flex;align-items:center;gap:6px;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
142
216
|
.dsa-head-label svg{flex:none;width:14px;height:14px}
|
|
@@ -162,6 +236,11 @@ window.__ModuleLoader__.load({
|
|
|
162
236
|
.dsa-actions{display:flex;gap:6px;flex-wrap:wrap;margin-top:6px}
|
|
163
237
|
.dsa-button{border:0;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);border-radius:var(--dsw-radius-sm);padding:4px 10px;cursor:pointer;font:inherit;line-height:16px}
|
|
164
238
|
.dsa-button:active:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}
|
|
239
|
+
.dsa-choices{display:inline-flex;align-items:center;gap:2px;padding:2px;border-radius:var(--dsw-radius-sm);background:var(--dsw-alias-bg-layer-2);flex:none}
|
|
240
|
+
.dsa-choice{border:0;background:0 0;border-radius:calc(var(--dsw-radius-sm) - 1px);padding:2px 6px;color:var(--dsw-alias-label-secondary);font:inherit;font-size:11px;line-height:14px;cursor:pointer}
|
|
241
|
+
@media (hover:hover){.dsa-choice:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}}
|
|
242
|
+
.dsa-choice:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}
|
|
243
|
+
.dsa-choice:disabled{opacity:.5;cursor:default}
|
|
165
244
|
.dsa-button:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
166
245
|
.dsa-button:disabled{opacity:.5;cursor:default}
|
|
167
246
|
.dsa-button:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px}
|
|
@@ -284,6 +363,8 @@ window.__ModuleLoader__.load({
|
|
|
284
363
|
if (notice === null || notice === undefined || notice === 'stale') return null
|
|
285
364
|
if (notice === 'testPlayed') return { text: `\u2713 ${t('panel.testPlayed')}` }
|
|
286
365
|
if (notice === 'testUnavailable') return { text: t('panel.testUnavailable'), tone: 'error' }
|
|
366
|
+
if (notice === 'resumeRetried') return { text: `\u2713 ${t('panel.resumeRetried')}` }
|
|
367
|
+
if (notice === 'resumeFailed') return { text: t('panel.resumeFailed'), tone: 'error' }
|
|
287
368
|
if (notice === 'failed') {
|
|
288
369
|
return {
|
|
289
370
|
text: `${t('panel.saveFailed')}${snapshot.noticeStatus ? ` (${snapshot.noticeStatus})` : ''}`,
|
|
@@ -293,6 +374,59 @@ window.__ModuleLoader__.load({
|
|
|
293
374
|
return { text: `\u2713 ${t('panel.saved')}` }
|
|
294
375
|
}
|
|
295
376
|
|
|
377
|
+
const useLayoutEffect = typeof React.useLayoutEffect === 'function' ? React.useLayoutEffect : React.useEffect
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Place the popover above its trigger, clamped to the viewport.
|
|
381
|
+
*
|
|
382
|
+
* CSS anchor positioning kept the panel attached but did not keep it inside
|
|
383
|
+
* a smaller window: anchoring `left` to the trigger let a wide panel run
|
|
384
|
+
* off the right edge, and the `@position-try` fallbacks only moved it
|
|
385
|
+
* vertically. Measuring here means a resized window, a scrolled composer
|
|
386
|
+
* and a re-wrapped toolbar all end with the panel fully on screen.
|
|
387
|
+
* @param {HTMLElement} panel
|
|
388
|
+
*/
|
|
389
|
+
function placePanel(panel) {
|
|
390
|
+
const doc = globalThis.document
|
|
391
|
+
const win = globalThis.window
|
|
392
|
+
if (!panel || !doc || !win) return
|
|
393
|
+
const viewportW = win.innerWidth || doc.documentElement?.clientWidth || 0
|
|
394
|
+
const viewportH = win.innerHeight || doc.documentElement?.clientHeight || 0
|
|
395
|
+
if (viewportW === 0 || viewportH === 0) return
|
|
396
|
+
const margin = 12
|
|
397
|
+
const gap = 8
|
|
398
|
+
const clamp = (value, min, max) => Math.min(Math.max(value, min), max)
|
|
399
|
+
// The height cap belongs to the viewport, not to the content: a taller
|
|
400
|
+
// panel scrolls instead of poking out of a short window.
|
|
401
|
+
panel.style.maxHeight = `${Math.max(160, viewportH - margin * 2)}px`
|
|
402
|
+
const width = panel.offsetWidth
|
|
403
|
+
const height = panel.offsetHeight
|
|
404
|
+
const trigger = doc.querySelector('[data-dsa-anchor="stay-awake"]')
|
|
405
|
+
const rect = trigger && typeof trigger.getBoundingClientRect === 'function' ? trigger.getBoundingClientRect() : null
|
|
406
|
+
const anchored = rect !== null && (rect.width > 0 || rect.height > 0)
|
|
407
|
+
&& rect.bottom > 0 && rect.top < viewportH
|
|
408
|
+
let left
|
|
409
|
+
let top
|
|
410
|
+
if (anchored) {
|
|
411
|
+
left = clamp(rect.left, margin, Math.max(margin, viewportW - width - margin))
|
|
412
|
+
const above = rect.top - gap - height
|
|
413
|
+
if (above >= margin) {
|
|
414
|
+
top = above
|
|
415
|
+
} else {
|
|
416
|
+
const below = rect.bottom + gap
|
|
417
|
+
top = below + height <= viewportH - margin ? below : Math.max(margin, viewportH - height - margin)
|
|
418
|
+
}
|
|
419
|
+
} else {
|
|
420
|
+
// Trigger hidden (narrow layout) or scrolled away: stay reachable above
|
|
421
|
+
// the composer instead of anchoring to a zero-sized box.
|
|
422
|
+
left = clamp(Math.round((viewportW - width) / 2), margin, Math.max(margin, viewportW - width - margin))
|
|
423
|
+
top = Math.max(margin, viewportH - height - 120)
|
|
424
|
+
}
|
|
425
|
+
panel.style.left = `${Math.round(left)}px`
|
|
426
|
+
panel.style.top = `${Math.round(Math.max(margin, top))}px`
|
|
427
|
+
panel.dataset.positioned = 'true'
|
|
428
|
+
}
|
|
429
|
+
|
|
296
430
|
function Moon({ color }) {
|
|
297
431
|
return h(
|
|
298
432
|
'svg',
|
|
@@ -370,6 +504,7 @@ window.__ModuleLoader__.load({
|
|
|
370
504
|
{
|
|
371
505
|
type: 'button',
|
|
372
506
|
className: 'dsa-pill dsa-root',
|
|
507
|
+
'data-dsa-anchor': 'stay-awake',
|
|
373
508
|
'aria-expanded': snapshot.open === true,
|
|
374
509
|
'aria-haspopup': 'dialog',
|
|
375
510
|
onClick: () => store.toggle(),
|
|
@@ -391,6 +526,38 @@ window.__ModuleLoader__.load({
|
|
|
391
526
|
function Panel({ store, t, act }) {
|
|
392
527
|
const snapshot = useStore(store)
|
|
393
528
|
const open = snapshot.open === true
|
|
529
|
+
const panelRef = React.useRef(null)
|
|
530
|
+
|
|
531
|
+
// Reposition on open, on viewport changes, on composer scroll and when
|
|
532
|
+
// the panel's own size changes (status rows, locale switch, notice).
|
|
533
|
+
useLayoutEffect(() => {
|
|
534
|
+
if (!open) return undefined
|
|
535
|
+
const panel = panelRef.current
|
|
536
|
+
if (panel === null) return undefined
|
|
537
|
+
let frame = 0
|
|
538
|
+
const schedule = () => {
|
|
539
|
+
if (frame !== 0) return
|
|
540
|
+
if (typeof globalThis.requestAnimationFrame === 'function') {
|
|
541
|
+
frame = globalThis.requestAnimationFrame(() => {
|
|
542
|
+
frame = 0
|
|
543
|
+
placePanel(panel)
|
|
544
|
+
})
|
|
545
|
+
} else {
|
|
546
|
+
placePanel(panel)
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
placePanel(panel)
|
|
550
|
+
const observer = typeof globalThis.ResizeObserver === 'function' ? new globalThis.ResizeObserver(schedule) : null
|
|
551
|
+
observer?.observe(panel)
|
|
552
|
+
globalThis.window?.addEventListener('resize', schedule)
|
|
553
|
+
globalThis.window?.addEventListener('scroll', schedule, true)
|
|
554
|
+
return () => {
|
|
555
|
+
observer?.disconnect()
|
|
556
|
+
globalThis.window?.removeEventListener('resize', schedule)
|
|
557
|
+
globalThis.window?.removeEventListener('scroll', schedule, true)
|
|
558
|
+
if (frame !== 0 && typeof globalThis.cancelAnimationFrame === 'function') globalThis.cancelAnimationFrame(frame)
|
|
559
|
+
}
|
|
560
|
+
}, [open])
|
|
394
561
|
useTick(open)
|
|
395
562
|
const status = snapshot.status
|
|
396
563
|
const failures = snapshot.failures
|
|
@@ -399,7 +566,9 @@ window.__ModuleLoader__.load({
|
|
|
399
566
|
const enabled = status === null ? true : status.enabled !== false
|
|
400
567
|
const allowDisplaySleep = (status === null ? 'system' : status.scope) === 'system'
|
|
401
568
|
const soundOn = status === null ? true : status.sound !== false
|
|
402
|
-
const
|
|
569
|
+
const autoResumeOn = status === null ? true : status.autoResume !== false
|
|
570
|
+
const resume = status !== null && status.resume !== null && typeof status.resume === 'object' ? status.resume : null
|
|
571
|
+
const staleHost = status !== null && status.protocol !== PROTOCOL
|
|
403
572
|
const counts = status && status.counts ? status.counts : { agents: 0, maintenance: 0, jobs: 0 }
|
|
404
573
|
const holdLeft = status && typeof status.manualUntil === 'number' && status.manualUntil > Date.now()
|
|
405
574
|
? status.manualUntil - Date.now()
|
|
@@ -425,6 +594,16 @@ window.__ModuleLoader__.load({
|
|
|
425
594
|
|
|
426
595
|
if (!open) return null
|
|
427
596
|
|
|
597
|
+
const resumeHint = resume === null
|
|
598
|
+
? t('panel.autoResumeHint')
|
|
599
|
+
: resume.state === 'waiting'
|
|
600
|
+
? t('panel.resumeWaiting')
|
|
601
|
+
: resume.state === 'retrying'
|
|
602
|
+
? t('panel.resumeRetrying')
|
|
603
|
+
: resume.state === 'failed'
|
|
604
|
+
? t('panel.resumeFailed')
|
|
605
|
+
: t('panel.autoResumeHint')
|
|
606
|
+
|
|
428
607
|
const backend = backendInfo(t, status)
|
|
429
608
|
const rows = [
|
|
430
609
|
[t('detail.sources'), `${t('sources.agents')} ${counts.agents ?? 0} · ${t('sources.maintenance')} ${counts.maintenance ?? 0} · ${t('sources.jobs')} ${counts.jobs ?? 0}`],
|
|
@@ -452,7 +631,7 @@ window.__ModuleLoader__.load({
|
|
|
452
631
|
|
|
453
632
|
return h(
|
|
454
633
|
'div',
|
|
455
|
-
{ className: 'dsa-panel', role: 'dialog', 'aria-label': t('brand') },
|
|
634
|
+
{ className: 'dsa-panel', role: 'dialog', 'aria-label': t('brand'), ref: panelRef },
|
|
456
635
|
stylesheet === null ? h('style', { key: 'css' }, CSS) : null,
|
|
457
636
|
h(
|
|
458
637
|
'div',
|
|
@@ -501,14 +680,35 @@ window.__ModuleLoader__.load({
|
|
|
501
680
|
'div',
|
|
502
681
|
{ className: 'dsa-row' },
|
|
503
682
|
h('span', { className: 'dsa-grow' }, t('panel.sound')),
|
|
504
|
-
h(
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
683
|
+
h(
|
|
684
|
+
'span',
|
|
685
|
+
{
|
|
686
|
+
className: 'dsa-choices',
|
|
687
|
+
role: 'group',
|
|
688
|
+
'aria-label': t('panel.testSound'),
|
|
689
|
+
title: t('panel.testSound'),
|
|
690
|
+
},
|
|
691
|
+
[['success', 'panel.testSuccess'], ['error', 'panel.testError'], ['question', 'panel.testQuestion']]
|
|
692
|
+
.map(([kind, key]) => h('button', {
|
|
693
|
+
key: kind,
|
|
694
|
+
type: 'button',
|
|
695
|
+
className: 'dsa-choice',
|
|
696
|
+
disabled: unreachable || staleHost,
|
|
697
|
+
title: `${t('panel.testSound')} · ${t(key)}`,
|
|
698
|
+
onClick: () => act({ action: 'test-sound', kind }),
|
|
699
|
+
}, t(key))),
|
|
700
|
+
),
|
|
510
701
|
switchOf(soundOn, () => act({ action: 'set-sound', enabled: !soundOn }), t('panel.sound')),
|
|
511
702
|
),
|
|
703
|
+
h(
|
|
704
|
+
'div',
|
|
705
|
+
{ className: 'dsa-row' },
|
|
706
|
+
h('span', { className: 'dsa-grow' },
|
|
707
|
+
h('div', null, t('panel.autoResume')),
|
|
708
|
+
h('div', { className: 'dsa-sub' }, resumeHint),
|
|
709
|
+
),
|
|
710
|
+
switchOf(autoResumeOn, () => act({ action: 'set-auto-resume', enabled: !autoResumeOn }), t('panel.autoResume'), staleHost),
|
|
711
|
+
),
|
|
512
712
|
),
|
|
513
713
|
h(
|
|
514
714
|
'div',
|
|
@@ -584,12 +784,25 @@ window.__ModuleLoader__.load({
|
|
|
584
784
|
apply(ctx) {
|
|
585
785
|
const t = ctx.locale.bind(NS)
|
|
586
786
|
|
|
787
|
+
// DSH ships Simplified Chinese but not Traditional; a language pack may
|
|
788
|
+
// extend the catalog. Falling back to `zh` means the rest of the GUI
|
|
789
|
+
// stays readable, and only this plugin's copy switches to 繁體中文.
|
|
790
|
+
ctx.effect(() => {
|
|
791
|
+
try {
|
|
792
|
+
return ctx.locale.addLanguage({ id: 'zh-Hant', label: '繁體中文', fallback: 'zh' })
|
|
793
|
+
} catch {
|
|
794
|
+
// Already contributed (another language pack, or a reload): the
|
|
795
|
+
// dictionary registration below is what actually matters.
|
|
796
|
+
return () => {}
|
|
797
|
+
}
|
|
798
|
+
}, 'stay-awake: zh-Hant language')
|
|
799
|
+
|
|
587
800
|
ctx.effect(() => {
|
|
588
801
|
const disposers = []
|
|
589
802
|
try {
|
|
590
|
-
disposers.push(ctx.locale.register(NS, { zh: ZH, en: EN }))
|
|
803
|
+
disposers.push(ctx.locale.register(NS, { zh: ZH, en: EN, 'zh-Hant': ZHT }))
|
|
591
804
|
} catch {
|
|
592
|
-
for (const [locale, dict] of [['zh', ZH], ['en', EN]]) {
|
|
805
|
+
for (const [locale, dict] of [['zh', ZH], ['en', EN], ['zh-Hant', ZHT]]) {
|
|
593
806
|
try {
|
|
594
807
|
disposers.push(ctx.locale.register(NS, locale, dict))
|
|
595
808
|
} catch {
|
|
@@ -643,8 +856,17 @@ window.__ModuleLoader__.load({
|
|
|
643
856
|
const value = await response.json()
|
|
644
857
|
if (cancelled) return
|
|
645
858
|
delay = POLL_MIN_MS
|
|
646
|
-
const
|
|
859
|
+
const before = store.get().status
|
|
860
|
+
const clearStale = store.get().notice === 'stale' && value.protocol === PROTOCOL
|
|
647
861
|
store.set({ status: value, failures: 0, ...(clearStale ? { notice: null, noticeStatus: null } : {}) })
|
|
862
|
+
// The host performs the retry on its own clock, so the only way
|
|
863
|
+
// to report it is a transition between two polls.
|
|
864
|
+
const was = before && before.resume ? before.resume : null
|
|
865
|
+
const now = value && value.resume ? value.resume : null
|
|
866
|
+
if (was !== null && now !== null && was.state !== now.state) {
|
|
867
|
+
if (was.state !== 'retrying' && now.state === 'idle' && now.retries > was.retries) flashNotice('resumeRetried', null)
|
|
868
|
+
else if (was.state !== 'failed' && now.state === 'failed') flashNotice('resumeFailed', null)
|
|
869
|
+
}
|
|
648
870
|
} catch {
|
|
649
871
|
if (cancelled) return
|
|
650
872
|
delay = Math.min(Math.max(delay * 2, POLL_MIN_MS), POLL_MAX_MS)
|