dsh-instruction-memory 1.6.3 → 1.6.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 +154 -0
- package/README.md +35 -9
- package/lib/client.js +444 -101
- package/lib/index.js +17 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,160 @@
|
|
|
7
7
|
> 1.0.13 起由 CI 经 OIDC Trusted Publishing 发布(首个带 provenance 的版本)。
|
|
8
8
|
> 这些历史 tag **不应回填**——npm 上的版本号已被占用。
|
|
9
9
|
|
|
10
|
+
## [1.6.5] — 2026-11-25
|
|
11
|
+
|
|
12
|
+
第三轮手机适配(1.6.4)的**回归修复**。1.6.4 把八处确认改成了"confirmThen + 重放处理函数"的形态,
|
|
13
|
+
其中条目删除把动作写进了重放闭包、调用点后面没有语句 —— 在有真对话框的**桌面端与网页端**点"删除→
|
|
14
|
+
确定"什么都不发生(0 次 POST、无撤销条、无报错),而手机(无对话框)反而正常。本轮把这个状态机
|
|
15
|
+
**重写成不可能再犯的契约**,并给三处缺失的护栏补上用例。
|
|
16
|
+
|
|
17
|
+
### 修复(阻断)
|
|
18
|
+
|
|
19
|
+
- **桌面/网页的单条删除恢复**(`lib/client.js` 条目行按钮)。根因不是一处笔误,而是 1.6.4 的
|
|
20
|
+
`confirmThen` 契约本身反直觉:它在"真对话框点了确定"时返回 `false`(意思是"调用方继续执行
|
|
21
|
+
自己的动作"),却**不调用** `run`。八个调用点里七个把动作放在 `if` 之后、只有删除把动作塞进
|
|
22
|
+
`run`,于是那一处静默失效。**新契约(1.6.5)**:`confirmThen(message, action)` **总是**返回
|
|
23
|
+
"调用方应停止"——有对话框就直接执行 `action`,没有就把它停到面板内确认条,用户点【确认】后执行;
|
|
24
|
+
动作只有一份,不再有"重放处理函数"。八处全部改为 `confirmed` 参数 / 局部函数形态,
|
|
25
|
+
批量删除的确认移到工具栏调用点(`doBatch` 内部不再问)。
|
|
26
|
+
- **测试门禁不再短路**(`test-all.mjs`)。`npm test` 原来是 `a && b && c …`:本机装了第二份 DSH
|
|
27
|
+
时 host-range 一段红,后面七段(含 1.6.4 新增的 25 条移动端断言)**一条都没跑**,
|
|
28
|
+
这条 P0 就藏在"看起来只有兼容性一条问题"的日志后面。现在九段各自独立跑、逐段报退出码、
|
|
29
|
+
最后汇总;任一段失败整体仍失败,但**不会再隐藏后面的结论**。
|
|
30
|
+
- **确认按钮双击只执行一次**。1.6.4 的按钮点击后没有一次性闸门,两次激活(双击/触摸抖动)会
|
|
31
|
+
发两条 `delete-entry`(服务端幂等救下),而 `import-data` / `restore-data` 从未验证过。
|
|
32
|
+
现在 `confirmFiringRef` 在同一个问题生命周期内只放行一次,下一次排队时才重置。
|
|
33
|
+
- **island 分块按"转义后"长度**。1.6.4 按原始 UTF-8 字节 12 KiB 切,忽略了 JSON 转义:
|
|
34
|
+
`"` 与 `\` 各翻一倍、C0 控制符变 6 单位。实测 `"`×20000 → 单帧 **24678** UTF-16 单位、
|
|
35
|
+
控制符载荷 → **73830**,都超过壳的 16 KiB(`island_messages.dart` 用 `raw.length` 计),
|
|
36
|
+
连一段真实的配置片段也到 **16396**。现在 `splitForBridge()` 逐 code point 计
|
|
37
|
+
`islandJsonCost`(引号/反斜杠 2、控制符 6、代理对 2、其余 1),把信封本身也计入预算;
|
|
38
|
+
`mobile-shape-test` 增加引号/反斜杠/换行/控制符/真实配置片段五组用例,并静态断言
|
|
39
|
+
`sendToAppBridge` 必须使用它(只测 helper 会在实现被换回时仍然绿——这正是 1.6.4 漏检的原因)。
|
|
40
|
+
|
|
41
|
+
### 修复(授权与数据面)
|
|
42
|
+
|
|
43
|
+
- **跨目标免确认(arm 泄漏)被根除**。1.6.4 用"文案字符串"当一次性凭据:重放处理函数时若在到达
|
|
44
|
+
`confirmThen` 之前早退(`busy`、空选择、体积判定),凭据会残留,下一次**同一文案**的动作
|
|
45
|
+
(删快照 / 整体恢复 / 导入的文案都是常量)会直接执行、不再确认。新契约没有"凭据",确认时
|
|
46
|
+
直接执行那一次动作,因此不存在可泄漏状态。
|
|
47
|
+
- **批量删除的目标锁定**。排队期间改动选择时,文案写"删除 3 条"、实际可能删 N 条;现在批量
|
|
48
|
+
动作把 ids 固定进闭包(`doBatch(op, value, ids)`)。
|
|
49
|
+
- **`window.DshGoIsland` 判据要求可调用**。`window.DshGoIsland = {}`(任意脚本,或共享设置页的
|
|
50
|
+
其它插件)以前会把整条移动分支打开:不发 blob 下载、反馈表单换成说明、确认走面板。
|
|
51
|
+
现在判据是 `typeof postMessage === 'function'`,与 `sendToAppBridge` 一致。
|
|
52
|
+
- **导出面板的 JSON 会自清**。全量 store(全部配置集 + 形象)渲染后常驻屏幕,会被任务切换
|
|
53
|
+
缩略图/共享屏幕看到,Android ≤9 还会留在剪贴板。现在 3 分钟后自动清空,卸载时也清。
|
|
54
|
+
- **冲突覆盖保存改为正常确认**。`editor.conflictOverwrite` 是唯一在 WebView 上从"静默拒绝"变成
|
|
55
|
+
"静默同意"的 `allow` 回退(会覆盖另一窗口的修改),现在走面板确认;取消编辑与源码重载
|
|
56
|
+
仍保留"无法弹框就放行"的语义(不丢已保存数据)。
|
|
57
|
+
- **打开编辑器时收起待确认条**。1.6.4 的确认条只在列表视图渲染,排队后点编辑会让动作"悬空"。
|
|
58
|
+
|
|
59
|
+
### 修复(兼容性守卫)
|
|
60
|
+
|
|
61
|
+
- **LIVE GUARD 不再把"桌面壳版本"当成运行时版本**。`runtime.json` 的 `desktopVersion` 是**壳**
|
|
62
|
+
版本;宿主自己的兼容门比较的是 `@deepseek-ai/dsh`。官方装两者相等所以从未暴露,而本机的
|
|
63
|
+
`DeepSeek Harness Uncensored` 用日历号 `2026.1123.0` 包着一个区里看不到的运行时,
|
|
64
|
+
guard 于是报 `NOT COVERED` 并建议往 `COVERED_LINES` 插一行 2026 —— 那会把"从未启动过的宿主"
|
|
65
|
+
写进 `peerDependencies`/`dsh.engines.dsh` 与市场卡片。
|
|
66
|
+
现在 guard 只读 `resources/app/dsh/node_modules/@deepseek-ai/dsh/package.json`;读不到(运行时
|
|
67
|
+
在 `app.asar` 里)就打印 `SKIP … runtime version unavailable`,**不**断言一个宿主门不使用的数字。
|
|
68
|
+
声明区间没有改:`2026.1123.0` 仍是**未声明**宿主。
|
|
69
|
+
|
|
70
|
+
### 可访问性
|
|
71
|
+
|
|
72
|
+
- 条目行的删除按钮补 `aria-label`(含条目标题)。此前页面里同时有集合删除、快照删除、批量删除
|
|
73
|
+
与条目删除,四个按钮的可见文本都是"删除",屏幕阅读器无法区分——测试也因此点错过目标。
|
|
74
|
+
|
|
75
|
+
### 测试
|
|
76
|
+
|
|
77
|
+
- `ui-test.mjs` +2 组:可信对话框点删除 → 条目恰减 1;无对话框 → 确认条出现、连点两次仍只删 1 条。
|
|
78
|
+
- `mobile-shape-test.mjs` +7 组:转义密集载荷的帧长度、拼回一致性、旧预算的回归护栏、
|
|
79
|
+
`sendToAppBridge` 的静态连线断言、桥 stub 与可调用桥的判据。
|
|
80
|
+
- `lint.mjs` 新增**形状门禁**:`confirmThen(` 的第二个实参不得含 `send(`(动作不得写在重放闭包里)。
|
|
81
|
+
这条规则直接对应 1.6.4 的 P0,静态可拦。
|
|
82
|
+
- 三处变异验证(改坏必须变红,均已还原):把动作写回闭包 → lint 红;把分块换回原始字节 →
|
|
83
|
+
帧断言红;新契约下删除用例本身即护栏。
|
|
84
|
+
|
|
85
|
+
### 已知边界
|
|
86
|
+
|
|
87
|
+
- 真实 Electron 渲染进程的点击仍是未验证项:本报告的证据链是"真实 React shim + 真实路由 +
|
|
88
|
+
真实 store",不是真窗口录制。代码路径已由 lint + ui-test 双向锁定。
|
|
89
|
+
- `2026.1123.0`(Uncensored 安装)**未声明支持**:要支持它必须在那个宿主上真跑一次
|
|
90
|
+
(装载、注入进组装后的提示、路由应答、设置页下发)再扩声明;本轮只把 guard 的假红改成 SKIP。
|
|
91
|
+
- 无 Android 真机:手机侧仍为代码级结论(帧预算现在按壳的真实口径计算,但壳侧丢弃行为未在
|
|
92
|
+
设备上确认)。
|
|
93
|
+
- 工作区仍未提交(`mobile-shape-test.mjs` 与 `test-all.mjs` 是新增文件);不提交则别的机器/CI
|
|
94
|
+
的 `npm test` 会 `MODULE_NOT_FOUND`,`prepublishOnly` 会拒绝发布。
|
|
95
|
+
|
|
96
|
+
## [1.6.4] — 2026-11-21
|
|
97
|
+
|
|
98
|
+
DSH Go(Android + WebView island)适配批次(技术方案评审团三条线的结论)。**没有引入新的手机功能,
|
|
99
|
+
而是把三处"看起来能用、实际静默失效"的路径修掉**,并把 Android 分支第一次纳入自动化门禁。
|
|
100
|
+
|
|
101
|
+
先说一条被证实**不是**问题的事:1.6.3 的写门 fail-closed 在 DSH Go 上不可达。Go 跑的是 `dsh web`,
|
|
102
|
+
`dsh-web-app` 必然注入 `connection`,`writeGateRefusal` 在第一行就放行,手机端保存/删除/导入不受影响。
|
|
103
|
+
真机上唯一要确认的是面板没有出现「写操作已停用」警示条(或快照 `security.writeGate === 'fence'`)。
|
|
104
|
+
|
|
105
|
+
### 修复(阻断)
|
|
106
|
+
|
|
107
|
+
- **手机端八类确认操作静默无效**。DSH Go 的 WebView 没有 `WebChromeClient.onJsConfirm`
|
|
108
|
+
(`island_handle.dart` 只设 NavigationDelegate 与 `DshGoIsland` 通道),`window.confirm` 因此
|
|
109
|
+
**存在、不抛错、恒返回 false**;`askConfirm` 把它判成"用户点了取消",于是删除条目、批量删除、
|
|
110
|
+
删除形象、删除配置集、历史恢复、历史删除、从备份恢复、导入全都变成零反应的 no-op,连
|
|
111
|
+
`confirm.unavailable` 那句提示都永远走不到(它只在 `CONFIRM_UNAVAILABLE` 分支)。
|
|
112
|
+
1.6.3 把导入确认搬到宿主后更糟:客户端在 `askConfirm` 就 return,`confirm:true` 发不出去。
|
|
113
|
+
**修复**:新增 `confirmDialogsAreTrustworthy()`(UA 与 `DshGoIsland` 双判据);不可信时
|
|
114
|
+
`askConfirm` 返回 `CONFIRM_UNAVAILABLE` 而不是 `no`;八处调用点改走 `confirmThen()`,
|
|
115
|
+
把问题停到面板内确认条(【确认】/【取消】)并在确认后**重放同一个处理函数**(
|
|
116
|
+
用一次性 `armedConfirmRef` 放行,避免在无对话框环境里自我排队)。
|
|
117
|
+
|
|
118
|
+
- **手机端导出是假成功**。`sendToAppBridge` 只要 `postMessage` 不抛就 `return true`,面板随即显示
|
|
119
|
+
"已交给 DSH Go 保存"并 `return`——而 stock DSH Go 的 `parseIslandMessage` 没有 `save` 分支
|
|
120
|
+
(未知 `t` 返回 null 被丢弃),保底 JSON 也被跳过。用户以为有备份,卸载 App 时 rootfs 随包清空。
|
|
121
|
+
**修复**:桥改为"附加通道"——先渲染面板内完整 JSON,再尝试桥;文案改成"已发送 N 条消息,
|
|
122
|
+
无法确认文件是否落地,若分享面板没出现或没保存成功请用下面的完整 JSON"。
|
|
123
|
+
|
|
124
|
+
- **island 分块按字符、上限是字节**。`CHUNK = 6000` 是 JS code unit,协议上限是
|
|
125
|
+
`IslandMessageLimits.maxBytes` = 16 KB;实测 6000 个汉字序列化后 **18098 字节**(超 1714),
|
|
126
|
+
同长度 ASCII 只有 6098 字节。手机上的记忆几乎必然含中文,所以就算壳以后支持 `save`,第一块就超限。
|
|
127
|
+
**修复**:`splitByBytes()` 按 UTF-8 字节切、单块 12 KiB(留出 JSON 信封与 `"`/`\` 转义余量),
|
|
128
|
+
按 code point 迭代因此永不切开代理对;中文安全上限落在约 4 千字/块。
|
|
129
|
+
|
|
130
|
+
### 修复(正确性 / 可观测)
|
|
131
|
+
|
|
132
|
+
- **`writeGate` 的启动竞态**:`connection` 服务 attach / detach 时只写日志,不推快照,面板可能长期
|
|
133
|
+
显示过期的"写操作已停用"(而写入其实已可用)。现在两个边沿各推一次快照。
|
|
134
|
+
- **导出范围披露**:一次导出携带**全部配置集 + 用户形象**,而面板本身只显示激活集合。文案现在
|
|
135
|
+
写明「含 N 个配置集 / M 条指令 / K 个形象」。
|
|
136
|
+
- **手机上的反馈入口**:`send-feedback` 需要 SMTP 配置从环境变量进来,而 DSH Go 的壳
|
|
137
|
+
`environment().clear()` 后只填固定几项,按钮必然失败。Android 上改为一段说明,不再渲染表单。
|
|
138
|
+
- **fence-less 的 503 文案**补一句平台现实:DSH Go 里设不了环境变量,请在 App 内重启/升级 App,
|
|
139
|
+
或让 App 提供带该开关的构建。
|
|
140
|
+
|
|
141
|
+
### 测试
|
|
142
|
+
|
|
143
|
+
- 新增 **`mobile-shape-test.mjs`**(并入 `npm test`,27 条断言):按字节分块的三条不变量
|
|
144
|
+
(每块 ≤ 上限、可逐字节拼回、不切代理对)+ 回归护栏(旧的 6000 code unit 分块确实超限)+
|
|
145
|
+
对话框信任矩阵(普通浏览器 / `; wv)` WebView / 注入 `DshGoIsland` / confirm 缺失 / confirm 抛错 /
|
|
146
|
+
无 window),以及"WebView 回答 unavailable 而不是 no""unsaved-draft 仍然放行"。
|
|
147
|
+
- 该文件是本仓库第一次真正执行 Android 分支:此前 `grep isAndroidWebView|DshGoIsland` 在所有
|
|
148
|
+
`*.mjs` 里零命中。
|
|
149
|
+
|
|
150
|
+
### 已知边界(本轮不修,理由记在此)
|
|
151
|
+
|
|
152
|
+
- **无 `connection` 时"读"仍无闸门**:`export-data` / `read-source` 属只读方法,返回全量 store。
|
|
153
|
+
正确的收紧方式是"挂载时生成一次性 nonce 注入面板、读写都要求携带",但插件无法向宿主渲染的
|
|
154
|
+
客户端 bundle 注入秘密(`settings.section` 只给 React 组件,不给 HTML),因此本轮不采用。
|
|
155
|
+
手机上的实际边界是平台补丁 + 宿主 `connection`,两者都在时这条不成立。
|
|
156
|
+
- **SSE 32 条上限在 WebView 后台不关连接时可能被耗尽**:需要壳在 `onPause`/销毁时关闭 SSE
|
|
157
|
+
(README 已列为平台待办),插件侧无法区分"同一个 WebView 重连"与"新客户端"。
|
|
158
|
+
- **真机未验证**:`sharing` 面板取消后的临时文件清理、`AndroidManifest` 的 `allowBackup`
|
|
159
|
+
(决定 rootfs 里的指令与形象是否会被自动备份上云)、cleartext 配置、Doze 下的 SSE、字号与深色。
|
|
160
|
+
- README 里「无 `--patch` 时鉴权回退成仅回环、无鉴权」这句现在限定为**宿主自带路由**:
|
|
161
|
+
1.6.3 起插件自己也会调 `connection.requestRejection`,只要 `connection` 服务在树里,
|
|
162
|
+
本插件路由仍要求登录 cookie。
|
|
163
|
+
|
|
10
164
|
## [1.6.3] — 2026-11-20
|
|
11
165
|
|
|
12
166
|
第三轮审计(技术方案评审团:架构 / 应用安全 / 验收三条线)的修复批次。**一条阻断级缺陷**:
|
package/README.md
CHANGED
|
@@ -771,9 +771,12 @@ content-type 校验兜底;在**没有**门的 profile 里,1.6.1 起「写方
|
|
|
771
771
|
- 没有 `connection` 服务时,**所有修改方法返回 503**,拒绝文案说明原因;读操作照常,设置页能
|
|
772
772
|
打开查看。设置页读取快照里的 `security.writeGate`(`fence` / `opt-in` / `refused`),在用户
|
|
773
773
|
动手之前就把这件事显示出来。
|
|
774
|
-
-
|
|
774
|
+
- 单用户设备(沙箱 / 自建 headless)若接受该暴露面,设
|
|
775
775
|
`DSH_INSTRUCTION_MEMORY_ALLOW_UNGUARDED_WRITES=1` 后重启,恢复原来的来源标记判据(仍只挡
|
|
776
776
|
浏览器跨站,不是身份校验)。
|
|
777
|
+
**DSH Go(Android)不适用这一条**:App 内的宿主进程由壳以 `environment().clear()` 启动、
|
|
778
|
+
只填固定几项变量,用户设不了这个开关(见下文「DSH Go」一节);手机上的写操作依赖宿主
|
|
779
|
+
`connection` 服务 + 平台补丁,两者都在时写门是 `fence`,根本不需要这个变量。
|
|
777
780
|
- 真正的边界仍是宿主的 `connection` 服务;或设 `DSH_INSTRUCTION_MEMORY_REQUIRE_AUTH_FENCE=1`
|
|
778
781
|
让整条路由 fail-closed(连只读方法都是 503)。
|
|
779
782
|
|
|
@@ -800,7 +803,7 @@ content-type 校验兜底;在**没有**门的 profile 里,1.6.1 起「写方
|
|
|
800
803
|
恢复可写时,才设:
|
|
801
804
|
|
|
802
805
|
```bash
|
|
803
|
-
#
|
|
806
|
+
# 沙箱 / 自建 headless,接受该风险时才设(DSH Go 的 App 内进程设不了这个变量)
|
|
804
807
|
DSH_INSTRUCTION_MEMORY_ALLOW_UNGUARDED_WRITES=1
|
|
805
808
|
```
|
|
806
809
|
|
|
@@ -886,8 +889,13 @@ DSH Go 给官方 Web 服务器包了一层**构建期补丁** `runtime/patches/r
|
|
|
886
889
|
上面几节描述的"无鉴权"缺口只适用于桌面端 / 网页端的端口。
|
|
887
890
|
|
|
888
891
|
⚠️ 这层保护是**平台属性,不是插件属性**:在 guest shell 里手动 `dsh web`(不带 `--patch`),
|
|
889
|
-
或在 guest
|
|
890
|
-
|
|
892
|
+
或在 guest 内把内核升级到补丁锚点对不上的版本,**宿主自带路由**的鉴权就回退成"仅回环、无鉴权"。
|
|
893
|
+
判断装机是否仍受保护,只看启动命令行里有没有 `--patch /etc/dsh-app/dsh-web.patch.yml`。
|
|
894
|
+
|
|
895
|
+
> **1.6.4 更正**:上面这句过去被读成"本插件路由也随之失守",那是错的。插件拿到 `connection`
|
|
896
|
+
> 服务后**自己**也会对每个请求调用 `connection.requestRejection(req)`(`rejectUntrustedCaller`),
|
|
897
|
+
> 所以只要 `connection` 在服务树里,即使壳层补丁缺席,`/instruction-memory/api` 仍然要求登录
|
|
898
|
+
> cookie;无补丁影响的是宿主自己的路由。真正的兜底仍是 `REQUIRE_AUTH_FENCE=1` 与平台补丁。
|
|
891
899
|
|
|
892
900
|
## 兼容性
|
|
893
901
|
|
|
@@ -897,6 +905,14 @@ DSH Go 给官方 Web 服务器包了一层**构建期补丁** `runtime/patches/r
|
|
|
897
905
|
| --- | --- | --- |
|
|
898
906
|
| **`peerDependencies`**(`@deepseek-ai/dsh-system-prompt`) | **宿主**:`evaluatePluginCompatibility()`(`dsh-app-boot`),在**安装**与 **profile 启动**时执行 | **门禁之一**,不是唯一。1.5.7 起两处实测结论必须同时写在这里:① 门禁读的是**宿主自身版本**(`getDshRuntimeVersion()` → `dsh-app-boot` 的 package.json),并用 `{ includePrerelease: true }` 求值,所以预发布行不会被误判;② 在 `0.2.2-rc.3` 的宿主实现里**存在 `engines.dsh` 时 `peerDependencies` 的区间被忽略**(`dsh-app-boot/src/plugin-compatibility.ts:52`)——也就是说这段 peer 区间可能完全不参与判定,只用来在报错时点名。本仓库仍让两处**逐字节同值**(1.6.1 删掉了无人读取的第三处),就是为了不依赖"到底哪一处生效"。这条已从"真正的门禁"更正:**能证明它生效的只有实测,不能靠读声明推断** |
|
|
899
907
|
| `dsh.engines.dsh` | 插件市场(第三方,服务端读取) | 市场卡片上的兼容性判定与展示 |
|
|
908
|
+
|
|
909
|
+
> **1.6.5:LIVE GUARD 只断言"运行时版本",读不到就 SKIP。** `runtime.json` 里的
|
|
910
|
+
> `desktopVersion` 是**桌面壳**版本,而宿主自己的兼容门比较的是 `@deepseek-ai/dsh`。官方装两者
|
|
911
|
+
> 相等,所以这个区别一直没暴露;`DeepSeek Harness Uncensored` 用日历号 `2026.1123.0` 包着一个
|
|
912
|
+
> 在 `app.asar` 里的运行时,guard 曾据此报 `NOT COVERED` 并建议往 `COVERED_LINES` 插一行 2026
|
|
913
|
+
> ——那会把从未启动过的宿主写进声明与市场卡片。现在读不到运行时版本就打印
|
|
914
|
+
> `SKIP … runtime version unavailable`,声明区间不变:**2026.1123.0 属未声明宿主**,
|
|
915
|
+
> 要支持它必须在那个宿主上真跑一次再扩声明。
|
|
900
916
|
| ~~`dsh.compatibility.dsh`~~ | **1.6.1 已删除**:`dsh-app-boot`、`dsh-client-ui-plugin-manager`、`dshmarket` 全树 grep 无读取方 | 曾经只是人类可读的重复声明,留在包里只会让人以为"改了这里就放宽了兼容" |
|
|
901
917
|
|
|
902
918
|
**1.0.14 之前这里只有后两处,没有 `peerDependencies`**——而宿主的门禁在读到缺失的 `peerDependencies` 时会直接 `return undefined`(`if (!Object.hasOwn(fields, "peerDependencies")) return void 0`),也就是**跳过检查**。换句话说,范围之外的宿主在此之前可以装上而**没有任何拦截或警告**;那串范围当时只是市场元数据,不是门禁。1.0.14 补上 peer 之后,它才真正生效。
|
|
@@ -1063,7 +1079,7 @@ DSH Go(Android 客户端)内置的引擎就是**真实 DSH**,锁定 `@deep
|
|
|
1063
1079
|
- **双端记忆不共享**:手机与"遥控 PC"各自维护自己的 `memory.json`,没有同步——这是当前形态,
|
|
1064
1080
|
不是缺陷。
|
|
1065
1081
|
|
|
1066
|
-
#### Android / WebView 适配(1.5.5
|
|
1082
|
+
#### Android / WebView 适配(1.5.5 起,1.6.4 补齐确认与导出)
|
|
1067
1083
|
|
|
1068
1084
|
WebView 不是浏览器:它能把 `window.prompt` 保留成函数却永不弹框,能暴露 `<a download>` 却没有
|
|
1069
1085
|
下载管线。这两处以前都是**点了没反应、也不报错**,而它们恰好是手机上数据进出口的一半。现在插件侧
|
|
@@ -1071,7 +1087,8 @@ WebView 不是浏览器:它能把 `window.prompt` 保留成函数却永不弹
|
|
|
1071
1087
|
|
|
1072
1088
|
| 场景 | WebView 上的行为 | 依据 |
|
|
1073
1089
|
| --- | --- | --- |
|
|
1074
|
-
| 导出 |
|
|
1090
|
+
| 导出 | **先**把完整 JSON 渲染在面板里(全选即可复制),再尝试岛通道;桥只算附加通道,提示语是"已发送 N 条、无法确认是否落地",不再谎报"已交给 DSH Go 保存"。分块按 UTF-8 **字节**(12 KiB/条),中文不再超过 16 KB 上限 | `client.js` 的 `isAndroidWebView()` / `splitByBytes()` / `exportFallback` 分支 |
|
|
1091
|
+
| 删除 / 导入 / 恢复 / 历史回滚 | `window.confirm` 在该形态下**存在但恒返回 false**(不弹框),旧代码把它读成"用户取消",八类操作因此静默无效且没有提示。1.6.4 起判为"问不了",把问题**停到面板内确认条**(【确认】/【取消】),确认后重放同一处理函数——手机上现在真的能删、能导入 | `confirmDialogsAreTrustworthy()` + `confirmThen()` + `pendingConfirm` |
|
|
1075
1092
|
| 导入 / 从备份恢复 | **壳已实现文件选择**(`island_handle.dart:197` 的 `_files.attach()` → `web_file_chooser.dart:26` 的 `setOnShowFileSelector` → 原生 `dsh/web-files` 通道,content:// 校验 + 按文档代际取消);面板那行提示只是兜底:页面不是 http(s)、`canChoose()` 为假、或旧版 App 时,请改用「源码模式」粘贴 JSON | 2026-11-12 读 DSH Go 源码确认 |
|
|
1076
1093
|
| 批量加标签 | 不再调用 `window.prompt`:WebView 返回的 `null` 被判为"问不了",直接走内联输入框 | `batchTagOutcome(..., { nullMeansUnavailable: true })` |
|
|
1077
1094
|
| 实时更新 | 连续 6 次(≈30 秒)订阅失败后显示「实时更新已断开,请重新载入」;收到下一帧自动清除 | `source.onerror` 计数 |
|
|
@@ -1082,16 +1099,25 @@ WebView 不是浏览器:它能把 `window.prompt` 保留成函数却永不弹
|
|
|
1082
1099
|
1. **保存/分享桥**:`<a download>` 的 `blob:` 字节 WebView 不会交给 `DownloadListener`,插件无法
|
|
1083
1100
|
自救。壳已有 `DshGoIsland` 通道和 `share_plus`,但没有任何"把这段文本存成文件"的消息类型 →
|
|
1084
1101
|
要新增一条(注意 island 消息协议上限只有 **16 KB**,`IslandMessageLimits.maxBytes`,而一次导出
|
|
1085
|
-
可达 MB
|
|
1086
|
-
|
|
1087
|
-
|
|
1102
|
+
可达 MB 级,必须分块)。**1.6.4 已完成插件侧的一半**:分块改为按 UTF-8 字节(12 KiB/条,
|
|
1103
|
+
不再按 6000 字符,后者对中文是 18 KB)、导出**先**把完整 JSON 渲染在面板里、桥只作为附加通道
|
|
1104
|
+
并如实显示"已发送 N 条,无法确认是否落地"。**壳侧仍然缺 `{t:'save'}` 的处理**,所以 stock App
|
|
1105
|
+
上导出依旧只能走面板复制;`island_messages.dart` 对未知 `t` 返回 null 并丢弃。
|
|
1106
|
+
2. **`onJsPrompt` / `onJsConfirm`**:webview_flutter 不暴露 JS 对话框,壳也没包 `WebChromeClient`。
|
|
1107
|
+
1.6.4 起插件不再依赖它们:`window.confirm` 在该形态下**存在但恒返回 false**,插件用
|
|
1108
|
+
`confirmDialogsAreTrustworthy()`(UA + `DshGoIsland` 双判据)把它判成"问不了",
|
|
1109
|
+
删除/导入/恢复改走**面板内确认条**并在确认后重放同一处理函数。壳补对话框已非必需。
|
|
1088
1110
|
3. **环境变量白名单**:壳会 `environment().clear()` 后逐项填(`DshProcess.kt:172-188`),加一个
|
|
1089
1111
|
`DSH_INSTRUCTION_MEMORY_ALLOW_EXTERNAL_BACKUP=1` 就能让备份目录走出 rootfs。
|
|
1112
|
+
`DSH_INSTRUCTION_MEMORY_ALLOW_UNGUARDED_WRITES` / `REQUIRE_AUTH_FENCE` 同理——**这三个变量
|
|
1113
|
+
在手机上用户设不了**,文档里不能再把它们当作手机的补救手段。
|
|
1090
1114
|
4. **WebView 销毁/后台时关闭 SSE**,否则半开连接会占满 32 条上限。
|
|
1091
1115
|
|
|
1092
1116
|
**纵深开关**:Android 的回环是全机共享的,没有宿主鉴权门时"仅回环"不构成边界。设置
|
|
1093
1117
|
`DSH_INSTRUCTION_MEMORY_REQUIRE_AUTH_FENCE=1` 后,缺少 `connection` 服务的 profile **直接
|
|
1094
1118
|
503**(fail-closed),宁可设置页打不开,也不留一个可被同机任何 App 改写的长期指令入口。
|
|
1119
|
+
**但这个变量在手机上设不了**(壳清空环境变量),所以手机端真实生效的边界仍是平台补丁 +
|
|
1120
|
+
宿主 `connection`;`REQUIRE_AUTH_FENCE` 只对自建部署有意义。
|
|
1095
1121
|
|
|
1096
1122
|
> **证据等级**:以上为代码级适配,`adb devices` 在本机为空,**没有任何真机验证**。
|
|
1097
1123
|
> 真机验收顺序见 `dsh-memory-verification/DSH-VERSION-COMPAT.md`;第一条永远先确认平台门在位
|
package/lib/client.js
CHANGED
|
@@ -155,6 +155,8 @@ window.__ModuleLoader__.load({
|
|
|
155
155
|
border:1px dashed var(--dsw-alias-border-l2,rgba(0,0,0,.18)); color:var(--dsw-alias-label-secondary,#8a9099); }
|
|
156
156
|
.im-err { font-size:12px; color:var(--dsw-alias-state-error-primary,#d94838); }
|
|
157
157
|
.im-ok { font-size:12px; color:var(--dsw-alias-state-success-primary,#18a058); }
|
|
158
|
+
.im-confirm { border:1px solid var(--dsw-alias-border-l2,#d9dde3); border-radius:8px; padding:8px 10px; margin:8px 0; background:var(--dsw-alias-bg-l2,#f5f6f8); }
|
|
159
|
+
.im-confirm-text { font-size:12px; line-height:1.5; margin-bottom:8px; }
|
|
158
160
|
.im-warn { font-size:12px; color:var(--dsw-alias-state-warn-primary,#d97706); }
|
|
159
161
|
.im-meta { font-size:11.5px; color:var(--dsw-alias-label-secondary,#8a9099); word-break:break-all; }
|
|
160
162
|
.im-pre { margin:0; padding:12px 14px; border-radius:8px; font-size:11.5px; line-height:1.65;
|
|
@@ -299,7 +301,8 @@ window.__ModuleLoader__.load({
|
|
|
299
301
|
'editor.needTitleOrContent': '请至少填写标题或指令内容',
|
|
300
302
|
'editor.conflictOverwrite': '这条记忆刚被其他窗口或进程修改过。继续保存会用你当前的编辑内容覆盖对方的修改,确定要继续吗?',
|
|
301
303
|
'editor.confirmDiscard': '当前编辑内容尚未保存,确定放弃这些修改吗?',
|
|
302
|
-
'confirm.
|
|
304
|
+
'confirm.yes': '确认',
|
|
305
|
+
'confirm.no': '取消',
|
|
303
306
|
'body.expand': '展开全部',
|
|
304
307
|
'body.collapse': '收起',
|
|
305
308
|
'budget.label': '注入字数上限(字符)',
|
|
@@ -369,8 +372,9 @@ window.__ModuleLoader__.load({
|
|
|
369
372
|
'profiles.omitted': '本轮未包含',
|
|
370
373
|
'profiles.omittedTitle': '这张形象因注入字数上限未进入本轮提示',
|
|
371
374
|
'export.saved': '已请求保存。若保存框被取消、或下载被浏览器/系统拦下,文件不会出现——请重试,或改用下面的「完整 JSON」',
|
|
372
|
-
'export.savedToApp': '已交给 DSH Go 保存:在系统分享面板里选「保存到文件」即可',
|
|
373
375
|
'export.fallbackHint': '当前环境无法触发文件下载,完整 JSON 已放在下面:全选复制后自行保存',
|
|
376
|
+
'export.androidHint': '已把完整 JSON 放在下方(含 {sets} 个配置集、{entries} 条指令、{profiles} 个形象):手机端无法触发文件下载,请全选复制后自行保存。',
|
|
377
|
+
'export.bridgeHint': '已向 DSH Go 的岛通道发送 {chunks} 条消息(含 {sets} 个配置集、{entries} 条指令、{profiles} 个形象)。注意:当前 App 版本可能没有「保存为文件」的处理,面板无法确认文件是否落地——若系统分享面板没有出现或没有保存成功,请用下面的完整 JSON。',
|
|
374
378
|
'export.desktopHint': '桌面端:已尝试用浏览器下载通道保存,但宿主的下载处理只接管自身标记的链接,插件无法确认文件是否落地。下面的「完整 JSON」是保底通道——若下载目录里没有文件,请全选复制后自行保存。',
|
|
375
379
|
'export.fallbackClose': '关闭',
|
|
376
380
|
'import.webviewHint': 'Android / WebView 上若文件选择器不弹出,请改用「源码模式」粘贴 JSON',
|
|
@@ -401,6 +405,7 @@ window.__ModuleLoader__.load({
|
|
|
401
405
|
'entry.enabled': '启用',
|
|
402
406
|
'entry.edit': '编辑',
|
|
403
407
|
'entry.delete': '删除',
|
|
408
|
+
'entry.deleteAria': '删除指令「{title}」',
|
|
404
409
|
'entry.untitled': '未命名指令',
|
|
405
410
|
'entry.confirmDelete': '确定删除「{title}」?删除后无法恢复。',
|
|
406
411
|
'entry.when': '适用情形:{when}',
|
|
@@ -468,6 +473,7 @@ window.__ModuleLoader__.load({
|
|
|
468
473
|
'diag.issueSection': '注入错误',
|
|
469
474
|
// ---- 反馈邮件 ----
|
|
470
475
|
'feedback.section': '反馈',
|
|
476
|
+
'feedback.mobileUnavailable': '手机上无法发送反馈:该功能需要宿主进程带 SMTP 配置启动,而 DSH Go 的 App 内进程不继承外部环境变量。请改用桌面版反馈,或到插件仓库提交 issue。',
|
|
471
477
|
'feedback.show': '反馈',
|
|
472
478
|
'feedback.hide': '收起反馈',
|
|
473
479
|
'feedback.intro': '遇到问题或有功能建议?填写下面的表单,通过邮件发送给插件维护者。',
|
|
@@ -605,7 +611,8 @@ window.__ModuleLoader__.load({
|
|
|
605
611
|
'editor.needTitleOrContent': 'Fill in at least a title or the instruction content',
|
|
606
612
|
'editor.conflictOverwrite': 'Another window or process just changed this entry. Saving now replaces their edit with yours. Continue?',
|
|
607
613
|
'editor.confirmDiscard': 'The draft has unsaved changes. Discard them?',
|
|
608
|
-
'confirm.
|
|
614
|
+
'confirm.yes': 'Confirm',
|
|
615
|
+
'confirm.no': 'Cancel',
|
|
609
616
|
'body.expand': 'Show all',
|
|
610
617
|
'body.collapse': 'Show less',
|
|
611
618
|
'budget.label': 'Injection size limit (characters)',
|
|
@@ -675,8 +682,9 @@ window.__ModuleLoader__.load({
|
|
|
675
682
|
'profiles.omitted': 'Not in this turn',
|
|
676
683
|
'profiles.omittedTitle': 'This persona was dropped by the injection limit and did not reach this turn',
|
|
677
684
|
'export.saved': 'Save requested. If you cancelled the dialog or the download was blocked, no file is written — retry, or use the full JSON below',
|
|
678
|
-
'export.savedToApp': 'Handed to DSH Go — pick “Save to Files” in the system share sheet',
|
|
679
685
|
'export.fallbackHint': 'This environment cannot start a file download; the full JSON is below — select all and copy it',
|
|
686
|
+
'export.androidHint': 'The full JSON is below ({sets} sets, {entries} entries, {profiles} personas). This surface cannot start a file download — select all and copy it.',
|
|
687
|
+
'export.bridgeHint': 'Sent {chunks} message(s) to the DSH Go island channel ({sets} sets, {entries} entries, {profiles} personas). Note: this app build may have no "save as file" handler, so the panel cannot confirm a file landed — if no share sheet appeared or nothing was saved, use the full JSON below.',
|
|
680
688
|
'export.desktopHint': 'Desktop: the browser download path was attempted, but the host only claims its own marked links, so the plugin cannot confirm a file landed. The full JSON below is the guaranteed route — if nothing appeared in your downloads, copy it from there.',
|
|
681
689
|
'export.fallbackClose': 'Close',
|
|
682
690
|
'import.webviewHint': 'On Android / WebView, if the file picker does not open, paste the JSON into “Source mode” instead',
|
|
@@ -707,6 +715,7 @@ window.__ModuleLoader__.load({
|
|
|
707
715
|
'entry.enabled': 'Enabled',
|
|
708
716
|
'entry.edit': 'Edit',
|
|
709
717
|
'entry.delete': 'Delete',
|
|
718
|
+
'entry.deleteAria': 'Delete instruction “{title}”',
|
|
710
719
|
'entry.untitled': 'Untitled instruction',
|
|
711
720
|
'entry.confirmDelete': 'Delete “{title}”? This cannot be undone.',
|
|
712
721
|
'entry.when': 'Applies when: {when}',
|
|
@@ -774,6 +783,7 @@ window.__ModuleLoader__.load({
|
|
|
774
783
|
'diag.issueSection': 'Injection error',
|
|
775
784
|
// ---- feedback mail ----
|
|
776
785
|
'feedback.section': 'Feedback',
|
|
786
|
+
'feedback.mobileUnavailable': 'Feedback cannot be sent from the phone: it needs SMTP configuration in the host process, and the DSH Go shell clears the environment. Use the desktop build, or open an issue in the plugin repository.',
|
|
777
787
|
'feedback.show': 'Feedback',
|
|
778
788
|
'feedback.hide': 'Hide feedback',
|
|
779
789
|
'feedback.intro': 'Found a problem or have a suggestion? Send it to the plugin maintainer by email with the form below.',
|
|
@@ -1182,6 +1192,169 @@ window.__ModuleLoader__.load({
|
|
|
1182
1192
|
const CONFIRM_NO = 'no'
|
|
1183
1193
|
const CONFIRM_UNAVAILABLE = 'unavailable'
|
|
1184
1194
|
|
|
1195
|
+
/**
|
|
1196
|
+
* DSH Go island chunking, in BYTES (1.6.4).
|
|
1197
|
+
*
|
|
1198
|
+
* The bridge's ceiling is `IslandMessageLimits.maxBytes` = 16 KB, counted by
|
|
1199
|
+
* the shell as `raw.length` — UTF-16 units of the DECODED JSON string
|
|
1200
|
+
* (`island_messages.dart`). Two earlier budgets were wrong for that:
|
|
1201
|
+
* 6000 JS code units (a 6000-character CJK chunk serialised to 18098 bytes)
|
|
1202
|
+
* and then 12 KiB of raw UTF-8 (1.6.4), which ignored JSON escaping: `"` and
|
|
1203
|
+
* `\` cost two units each and a control character costs six, so a quote- or
|
|
1204
|
+
* backslash-heavy chunk (code, JSON, Windows paths) measured 24678 and a
|
|
1205
|
+
* control-character payload 73830 — both well past 16384. `splitForBridge`
|
|
1206
|
+
* below charges the ESCAPED cost per code point instead.
|
|
1207
|
+
*/
|
|
1208
|
+
const ISLAND_CHUNK_BYTES = 12 * 1024
|
|
1209
|
+
/** The shell's ceiling, in UTF-16 units of the serialised frame. */
|
|
1210
|
+
const ISLAND_FRAME_LIMIT = 16 * 1024
|
|
1211
|
+
|
|
1212
|
+
/** UTF-8 length of one code point (no Buffer/TextEncoder dependency). */
|
|
1213
|
+
function utf8SizeOf(ch) {
|
|
1214
|
+
const code = typeof ch.codePointAt === 'function' ? ch.codePointAt(0) : 0
|
|
1215
|
+
if (code <= 0x7f) return 1
|
|
1216
|
+
if (code <= 0x7ff) return 2
|
|
1217
|
+
if (code <= 0xffff) return 3
|
|
1218
|
+
return 4
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
/**
|
|
1222
|
+
* UTF-16 units one code point costs INSIDE a JSON string: `"` and `\` become
|
|
1223
|
+
* two-unit escapes, a C0 control becomes a six-unit `\u00XX`, a surrogate
|
|
1224
|
+
* pair is two units, everything else one. Exactly what `JSON.stringify`
|
|
1225
|
+
* does, without building the string per character.
|
|
1226
|
+
*/
|
|
1227
|
+
function islandJsonCost(ch) {
|
|
1228
|
+
const code = typeof ch.codePointAt === 'function' ? ch.codePointAt(0) : 0
|
|
1229
|
+
if (code === 0x22 || code === 0x5c) return 2
|
|
1230
|
+
if (code < 0x20) return 6
|
|
1231
|
+
if (code > 0xffff) return 2
|
|
1232
|
+
return 1
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
/**
|
|
1236
|
+
* Split `text` so that every FRAME — the JSON envelope plus the chunk, as
|
|
1237
|
+
* `JSON.stringify` would produce it — stays inside the shell's 16 KiB
|
|
1238
|
+
* ceiling, never cutting a surrogate pair. `id`/`name` are passed so the
|
|
1239
|
+
* envelope's own cost is charged against the budget; the fixed slack covers
|
|
1240
|
+
* `last` flipping and the chunking of the id (which is ASCII by design).
|
|
1241
|
+
*/
|
|
1242
|
+
function splitForBridge(text, name, id) {
|
|
1243
|
+
if (typeof text !== 'string' || text === '') return []
|
|
1244
|
+
const envelope = JSON.stringify({
|
|
1245
|
+
t: 'save', id: typeof id === 'string' ? id : 'im-xxxxxxxx', name: typeof name === 'string' ? name : '', data: '', last: false,
|
|
1246
|
+
}).length
|
|
1247
|
+
const budget = Math.max(256, ISLAND_FRAME_LIMIT - envelope - 64)
|
|
1248
|
+
const out = []
|
|
1249
|
+
let current = ''
|
|
1250
|
+
let units = 0
|
|
1251
|
+
for (const ch of text) {
|
|
1252
|
+
const cost = islandJsonCost(ch)
|
|
1253
|
+
if (units + cost > budget && current !== '') {
|
|
1254
|
+
out.push(current)
|
|
1255
|
+
current = ''
|
|
1256
|
+
units = 0
|
|
1257
|
+
}
|
|
1258
|
+
current += ch
|
|
1259
|
+
units += cost
|
|
1260
|
+
}
|
|
1261
|
+
if (current !== '') out.push(current)
|
|
1262
|
+
return out
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
/**
|
|
1266
|
+
* Split `text` so that every piece fits `maxBytes` of UTF-8, never cutting
|
|
1267
|
+
* a surrogate pair in half (iteration is by code point, so an emoji or a
|
|
1268
|
+
* CJK ext-B character can never be torn). An empty string yields no pieces.
|
|
1269
|
+
*/
|
|
1270
|
+
function splitByBytes(text, maxBytes) {
|
|
1271
|
+
if (typeof text !== 'string' || text === '') return []
|
|
1272
|
+
const limit = typeof maxBytes === 'number' && Number.isFinite(maxBytes) && maxBytes >= 256
|
|
1273
|
+
? Math.floor(maxBytes)
|
|
1274
|
+
: ISLAND_CHUNK_BYTES
|
|
1275
|
+
const out = []
|
|
1276
|
+
let current = ''
|
|
1277
|
+
let bytes = 0
|
|
1278
|
+
for (const ch of text) {
|
|
1279
|
+
const size = utf8SizeOf(ch)
|
|
1280
|
+
if (bytes + size > limit && current !== '') {
|
|
1281
|
+
out.push(current)
|
|
1282
|
+
current = ''
|
|
1283
|
+
bytes = 0
|
|
1284
|
+
}
|
|
1285
|
+
current += ch
|
|
1286
|
+
bytes += size
|
|
1287
|
+
}
|
|
1288
|
+
if (current !== '') out.push(current)
|
|
1289
|
+
return out
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
/**
|
|
1293
|
+
* UA half of the Android/WebView detection, at module scope so the dialog
|
|
1294
|
+
* probe below can use it. `isAndroidWebView()` (inside the panel) keeps the
|
|
1295
|
+
* same predicate; 1.6.4 also treats the presence of the island bridge as a
|
|
1296
|
+
* positive signal, because a custom UA would otherwise look like a desktop
|
|
1297
|
+
* browser and take the blob-download branch that can never work there.
|
|
1298
|
+
*/
|
|
1299
|
+
function looksLikeAndroidWebView() {
|
|
1300
|
+
try {
|
|
1301
|
+
const ua = typeof navigator !== 'undefined' && typeof navigator.userAgent === 'string'
|
|
1302
|
+
? navigator.userAgent
|
|
1303
|
+
: ''
|
|
1304
|
+
return /;\s*wv\)/i.test(ua) || (/Android/i.test(ua) && !/Chrome\/\d+/i.test(ua))
|
|
1305
|
+
} catch {
|
|
1306
|
+
return false
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
|
|
1310
|
+
/**
|
|
1311
|
+
* S3 (1.6.5): the island bridge counts only when it can actually take a
|
|
1312
|
+
* message. `window.DshGoIsland = {}` — set by any script, or by another
|
|
1313
|
+
* plugin sharing this settings page — used to flip the whole mobile branch
|
|
1314
|
+
* (no blob export, feedback form replaced by a note, confirmations pushed
|
|
1315
|
+
* onto the arm-leak route), while `sendToAppBridge` itself required
|
|
1316
|
+
* `postMessage`. Both judgments agree now.
|
|
1317
|
+
*/
|
|
1318
|
+
function hasIslandBridge(target) {
|
|
1319
|
+
try {
|
|
1320
|
+
const current = target === undefined
|
|
1321
|
+
? (typeof window !== 'undefined' ? window : undefined)
|
|
1322
|
+
: target
|
|
1323
|
+
return current !== undefined && current !== null
|
|
1324
|
+
&& current.DshGoIsland !== undefined && current.DshGoIsland !== null
|
|
1325
|
+
&& typeof current.DshGoIsland.postMessage === 'function'
|
|
1326
|
+
} catch {
|
|
1327
|
+
return false
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
/**
|
|
1332
|
+
* Can `window.confirm` be believed on this surface?
|
|
1333
|
+
*
|
|
1334
|
+
* DSH Go's WebView sets a NavigationDelegate and `DshGoIsland`, and NO
|
|
1335
|
+
* `WebChromeClient.onJsConfirm` (`island_handle.dart`). A confirm() there
|
|
1336
|
+
* does not throw and does not show anything: it returns `false`
|
|
1337
|
+
* immediately. `askConfirm` used to read that as "the user pressed
|
|
1338
|
+
* Cancel", so eight destructive actions — entry delete, bulk delete,
|
|
1339
|
+
* persona delete, set delete, history restore/delete, whole-store restore
|
|
1340
|
+
* and import — became silent no-ops on the phone. Since 1.6.5 the callers
|
|
1341
|
+
* park the question in the panel instead of relying on a dialog at all, so
|
|
1342
|
+
* there is no "unavailable" dead end left to explain.
|
|
1343
|
+
*
|
|
1344
|
+
* Electron already had a sibling problem with `prompt()` (exists, throws);
|
|
1345
|
+
* the WebView shape is the same class, one layer quieter.
|
|
1346
|
+
*/
|
|
1347
|
+
function confirmDialogsAreTrustworthy() {
|
|
1348
|
+
try {
|
|
1349
|
+
if (typeof window === 'undefined') return false
|
|
1350
|
+
if (looksLikeAndroidWebView()) return false
|
|
1351
|
+
if (hasIslandBridge()) return false
|
|
1352
|
+
return typeof window.confirm === 'function'
|
|
1353
|
+
} catch {
|
|
1354
|
+
return false
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1185
1358
|
/**
|
|
1186
1359
|
* The single gate every confirmation goes through.
|
|
1187
1360
|
*
|
|
@@ -1213,6 +1386,15 @@ window.__ModuleLoader__.load({
|
|
|
1213
1386
|
if (typeof window === 'undefined' || typeof window.confirm !== 'function') {
|
|
1214
1387
|
return fallback ? CONFIRM_YES : CONFIRM_UNAVAILABLE
|
|
1215
1388
|
}
|
|
1389
|
+
// A dialog that CANNOT be shown is not a "no" (1.6.4). On DSH Go the
|
|
1390
|
+
// function exists and answers `false` without ever rendering anything;
|
|
1391
|
+
// treating that as a cancel made every destructive action a silent
|
|
1392
|
+
// no-op. The callers now route CONFIRM_UNAVAILABLE to an in-panel
|
|
1393
|
+
// confirmation, so the action still happens — after the user actually
|
|
1394
|
+
// sees what it is.
|
|
1395
|
+
if (!confirmDialogsAreTrustworthy()) {
|
|
1396
|
+
return fallback ? CONFIRM_YES : CONFIRM_UNAVAILABLE
|
|
1397
|
+
}
|
|
1216
1398
|
try {
|
|
1217
1399
|
return window.confirm(message) === true ? CONFIRM_YES : CONFIRM_NO
|
|
1218
1400
|
} catch {
|
|
@@ -2097,6 +2279,79 @@ window.__ModuleLoader__.load({
|
|
|
2097
2279
|
const [diagFallback, setDiagFallback] = React.useState(null)
|
|
2098
2280
|
/** Export JSON rendered in-panel when the runtime has no download path. */
|
|
2099
2281
|
const [exportFallback, setExportFallback] = React.useState(null)
|
|
2282
|
+
/**
|
|
2283
|
+
* S4 (1.6.5): the rendered export holds the WHOLE store — every set and
|
|
2284
|
+
* every persona — and it used to stay on screen until the user closed it.
|
|
2285
|
+
* That put the full memory into the task-switcher thumbnail and any screen
|
|
2286
|
+
* share, and on Android ≤ 9 into a clipboard any app could read. It now
|
|
2287
|
+
* clears itself after a few minutes and on unmount; copying still works
|
|
2288
|
+
* immediately.
|
|
2289
|
+
*/
|
|
2290
|
+
const EXPORT_FALLBACK_TTL_MS = 180000
|
|
2291
|
+
const exportFallbackTimerRef = React.useRef(null)
|
|
2292
|
+
const stageExportFallback = (text) => {
|
|
2293
|
+
setExportFallback(text)
|
|
2294
|
+
if (exportFallbackTimerRef.current !== null) clearTimeout(exportFallbackTimerRef.current)
|
|
2295
|
+
exportFallbackTimerRef.current = setTimeout(() => {
|
|
2296
|
+
exportFallbackTimerRef.current = null
|
|
2297
|
+
setExportFallback(null)
|
|
2298
|
+
}, EXPORT_FALLBACK_TTL_MS)
|
|
2299
|
+
}
|
|
2300
|
+
const clearExportFallback = () => {
|
|
2301
|
+
if (exportFallbackTimerRef.current !== null) {
|
|
2302
|
+
clearTimeout(exportFallbackTimerRef.current)
|
|
2303
|
+
exportFallbackTimerRef.current = null
|
|
2304
|
+
}
|
|
2305
|
+
setExportFallback(null)
|
|
2306
|
+
}
|
|
2307
|
+
React.useEffect(() => () => {
|
|
2308
|
+
if (exportFallbackTimerRef.current !== null) {
|
|
2309
|
+
clearTimeout(exportFallbackTimerRef.current)
|
|
2310
|
+
exportFallbackTimerRef.current = null
|
|
2311
|
+
}
|
|
2312
|
+
}, [])
|
|
2313
|
+
/**
|
|
2314
|
+
* A confirmation waiting for an in-panel answer (1.6.4).
|
|
2315
|
+
*
|
|
2316
|
+
* DSH Go's WebView cannot show `window.confirm` and answers `false`
|
|
2317
|
+
* instead, so every destructive action used to fall into "the user said
|
|
2318
|
+
* no" and do nothing at all — no delete, no import, no restore, and not
|
|
2319
|
+
* even the "this runtime has no dialog" hint. When the dialog is
|
|
2320
|
+
* untrustworthy the question is parked here and rendered as a row with
|
|
2321
|
+
* 【确认】/【取消】; the action keeps working, one tap later.
|
|
2322
|
+
*/
|
|
2323
|
+
const [pendingConfirm, setPendingConfirm] = React.useState(null)
|
|
2324
|
+
/** R2 (1.6.5): one activation of the confirm button runs the action once. */
|
|
2325
|
+
const confirmFiringRef = React.useRef(false)
|
|
2326
|
+
/**
|
|
2327
|
+
* The single confirmation entry point (1.6.5 contract).
|
|
2328
|
+
*
|
|
2329
|
+
* It ALWAYS answers "the caller should stop": with a working dialog it runs
|
|
2330
|
+
* `action` itself; without one it parks the question and runs `action` when
|
|
2331
|
+
* the user confirms in the panel; on "no" it does nothing. There is no
|
|
2332
|
+
* path where the caller has to run the action as well, and no replay of a
|
|
2333
|
+
* handler — the 1.6.4 design ("return false means you continue, and the
|
|
2334
|
+
* closure is only used to replay the handler") is what made entry delete a
|
|
2335
|
+
* silent no-op on desktop and, later, what made a leftover approval leak
|
|
2336
|
+
* into the next action with the same wording.
|
|
2337
|
+
*
|
|
2338
|
+
* So every call site reads `if (confirmThen(message, action)) return` and
|
|
2339
|
+
* the action body exists in exactly one place.
|
|
2340
|
+
*/
|
|
2341
|
+
const confirmThen = (message, action) => {
|
|
2342
|
+
const ask = askConfirm(message)
|
|
2343
|
+
if (ask === CONFIRM_YES) {
|
|
2344
|
+
void action()
|
|
2345
|
+
return true
|
|
2346
|
+
}
|
|
2347
|
+
if (ask === CONFIRM_UNAVAILABLE) {
|
|
2348
|
+
// A fresh question re-arms the one-shot firing guard (R2).
|
|
2349
|
+
confirmFiringRef.current = false
|
|
2350
|
+
setPendingConfirm({ message, action })
|
|
2351
|
+
return true
|
|
2352
|
+
}
|
|
2353
|
+
return true
|
|
2354
|
+
}
|
|
2100
2355
|
/** True once the event stream has failed long enough to stop pretending. */
|
|
2101
2356
|
const [liveDown, setLiveDown] = React.useState(false)
|
|
2102
2357
|
// Feedback form: closed by default so the settings card stays compact.
|
|
@@ -2322,19 +2577,18 @@ window.__ModuleLoader__.load({
|
|
|
2322
2577
|
setBatchTagText('')
|
|
2323
2578
|
}
|
|
2324
2579
|
|
|
2325
|
-
async function doBatch(op, value) {
|
|
2326
|
-
|
|
2580
|
+
async function doBatch(op, value, fixedIds) {
|
|
2581
|
+
// S2 (1.6.5): the in-panel confirmation replays this handler, so the
|
|
2582
|
+
// selection could change between the question and the answer ("delete
|
|
2583
|
+
// 3 entries" then deleting N). The parked action carries its own ids.
|
|
2584
|
+
const ids = Array.isArray(fixedIds) ? fixedIds : liveSelected()
|
|
2327
2585
|
if (ids.length === 0) {
|
|
2328
2586
|
setError(t('batch.noneSelected'))
|
|
2329
2587
|
return
|
|
2330
2588
|
}
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
if (ask === CONFIRM_UNAVAILABLE) setError(t('confirm.unavailable'))
|
|
2335
|
-
return
|
|
2336
|
-
}
|
|
2337
|
-
}
|
|
2589
|
+
// The delete confirmation lives at the CALLER (the batch toolbar), not
|
|
2590
|
+
// here: 1.6.5's contract runs the action from inside confirmThen, so a
|
|
2591
|
+
// confirm inside this function would ask again on the replay.
|
|
2338
2592
|
const result = await send('batch', { op, ids, value, baseRev: revOf() })
|
|
2339
2593
|
if (result !== null && result.ok === true && op === 'delete') {
|
|
2340
2594
|
// Drop deleted ids from the selection; other ops keep it so several
|
|
@@ -2408,13 +2662,12 @@ window.__ModuleLoader__.load({
|
|
|
2408
2662
|
setError('')
|
|
2409
2663
|
}
|
|
2410
2664
|
|
|
2411
|
-
function removeProfile(profile) {
|
|
2665
|
+
function removeProfile(profile, confirmed) {
|
|
2412
2666
|
if (busy) return
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
if (ask === CONFIRM_UNAVAILABLE) setError(t('confirm.unavailable'))
|
|
2667
|
+
if (confirmed !== true) {
|
|
2668
|
+
confirmThen(t('profiles.confirmDelete', {
|
|
2669
|
+
name: profile.name !== '' ? profile.name : t('profiles.untitled'),
|
|
2670
|
+
}), () => removeProfile(profile, true))
|
|
2418
2671
|
return
|
|
2419
2672
|
}
|
|
2420
2673
|
void send('delete-profile', { id: profile.id, baseRev: revOf() })
|
|
@@ -2475,15 +2728,15 @@ window.__ModuleLoader__.load({
|
|
|
2475
2728
|
})
|
|
2476
2729
|
}
|
|
2477
2730
|
|
|
2478
|
-
function removeSet(set) {
|
|
2731
|
+
function removeSet(set, confirmed) {
|
|
2479
2732
|
if (busy) return
|
|
2480
2733
|
if (set.active === true) {
|
|
2481
2734
|
setError(t('sets.deleteActive'))
|
|
2482
2735
|
return
|
|
2483
2736
|
}
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2737
|
+
if (confirmed !== true) {
|
|
2738
|
+
confirmThen(t('sets.deleteConfirm', { name: set.name, entries: set.entries, profiles: set.profiles }),
|
|
2739
|
+
() => removeSet(set, true))
|
|
2487
2740
|
return
|
|
2488
2741
|
}
|
|
2489
2742
|
void send('delete-set', { id: set.id, baseRev: revOf() })
|
|
@@ -2516,7 +2769,7 @@ window.__ModuleLoader__.load({
|
|
|
2516
2769
|
if (next) void loadHistory()
|
|
2517
2770
|
}
|
|
2518
2771
|
|
|
2519
|
-
function rollbackTo(item) {
|
|
2772
|
+
function rollbackTo(item, confirmed) {
|
|
2520
2773
|
if (busy) return
|
|
2521
2774
|
// Restoring makes the Host read a whole file; a snapshot far larger
|
|
2522
2775
|
// than any real store is refused BEFORE the user confirms an operation
|
|
@@ -2527,10 +2780,10 @@ window.__ModuleLoader__.load({
|
|
|
2527
2780
|
setError(sizeVerdict.message)
|
|
2528
2781
|
return
|
|
2529
2782
|
}
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2783
|
+
if (confirmed !== true) {
|
|
2784
|
+
const when = new Date(item.epoch).toLocaleString()
|
|
2785
|
+
confirmThen(t('history.restoreConfirm', { time: when, rev: item.rev, name: item.name }),
|
|
2786
|
+
() => rollbackTo(item, true))
|
|
2534
2787
|
return
|
|
2535
2788
|
}
|
|
2536
2789
|
void send('history-restore', { name: item.name, baseRev: revOf() }).then((result) => {
|
|
@@ -2538,11 +2791,10 @@ window.__ModuleLoader__.load({
|
|
|
2538
2791
|
})
|
|
2539
2792
|
}
|
|
2540
2793
|
|
|
2541
|
-
function removeSnapshot(item) {
|
|
2794
|
+
function removeSnapshot(item, confirmed) {
|
|
2542
2795
|
if (busy) return
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
if (askDeleteHistory === CONFIRM_UNAVAILABLE) setError(t('confirm.unavailable'))
|
|
2796
|
+
if (confirmed !== true) {
|
|
2797
|
+
confirmThen(t('history.deleteConfirm'), () => removeSnapshot(item, true))
|
|
2546
2798
|
return
|
|
2547
2799
|
}
|
|
2548
2800
|
void send('history-delete', { name: item.name }).then((result) => {
|
|
@@ -2724,11 +2976,12 @@ window.__ModuleLoader__.load({
|
|
|
2724
2976
|
|
|
2725
2977
|
// ---- F14 whole-store restore (the "replace" door import does not open) ----
|
|
2726
2978
|
|
|
2727
|
-
async function handleRestoreFile(file) {
|
|
2979
|
+
async function handleRestoreFile(file, confirmed) {
|
|
2728
2980
|
try {
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2981
|
+
// 1.6.5 contract: confirmThen runs the action itself, so the replay
|
|
2982
|
+
// carries `confirmed` to skip this block instead of re-asking.
|
|
2983
|
+
if (confirmed !== true) {
|
|
2984
|
+
confirmThen(t('restore.confirm'), () => handleRestoreFile(file, true))
|
|
2732
2985
|
return
|
|
2733
2986
|
}
|
|
2734
2987
|
const text = typeof file.text === 'function'
|
|
@@ -2812,14 +3065,14 @@ window.__ModuleLoader__.load({
|
|
|
2812
3065
|
*/
|
|
2813
3066
|
function isAndroidWebView() {
|
|
2814
3067
|
try {
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
//
|
|
2819
|
-
//
|
|
2820
|
-
//
|
|
2821
|
-
|
|
2822
|
-
|
|
3068
|
+
// A6 (1.6.4): the bridge is a PROTOCOL-level signal, the UA is a
|
|
3069
|
+
// guess. The old predicate said "may report a stock Chromium UA" and
|
|
3070
|
+
// then relied on `Android && !Chrome/` — which a stock Chromium UA
|
|
3071
|
+
// fails. If the island bridge is present we are inside DSH Go,
|
|
3072
|
+
// whatever the UA claims; the UA check stays as the secondary hint
|
|
3073
|
+
// for the first paint, before the channel is injected.
|
|
3074
|
+
if (hasIslandBridge()) return true
|
|
3075
|
+
return looksLikeAndroidWebView()
|
|
2823
3076
|
} catch {
|
|
2824
3077
|
return false
|
|
2825
3078
|
}
|
|
@@ -2846,35 +3099,33 @@ window.__ModuleLoader__.load({
|
|
|
2846
3099
|
}
|
|
2847
3100
|
|
|
2848
3101
|
/**
|
|
2849
|
-
* Hand `text` to the DSH Go island bridge
|
|
2850
|
-
* message cap (`IslandMessageLimits.maxBytes`). The app reassembles them
|
|
2851
|
-
* and opens the system share sheet — the only export path a WebView has,
|
|
2852
|
-
* since it never hands a `blob:` to a download listener.
|
|
3102
|
+
* Hand `text` to the DSH Go island bridge in UTF-8-byte-bounded chunks.
|
|
2853
3103
|
*
|
|
2854
|
-
*
|
|
2855
|
-
*
|
|
3104
|
+
* `sent` means only "postMessage did not throw". The stock DSH Go build
|
|
3105
|
+
* has no `save` branch in `parseIslandMessage` (`island_messages.dart`:
|
|
3106
|
+
* an unknown `t` returns null and is dropped), so 1.6.4 no longer treats
|
|
3107
|
+
* this as "a file exists": the caller keeps the in-panel JSON on screen
|
|
3108
|
+
* and the notice says "requested", not "saved".
|
|
2856
3109
|
*/
|
|
2857
3110
|
async function sendToAppBridge(text, name) {
|
|
2858
3111
|
try {
|
|
2859
3112
|
const bridge = typeof window !== 'undefined' ? window.DshGoIsland : undefined
|
|
2860
|
-
if (bridge === undefined || bridge === null || typeof bridge.postMessage !== 'function')
|
|
3113
|
+
if (bridge === undefined || bridge === null || typeof bridge.postMessage !== 'function') {
|
|
3114
|
+
return { sent: false, chunks: 0 }
|
|
3115
|
+
}
|
|
2861
3116
|
const id = 'im-' + Date.now().toString(36) + Math.random().toString(36).slice(2, 8)
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
// own JSON document and a lone surrogate would not survive it.
|
|
2868
|
-
const code = text.charCodeAt(end - 1)
|
|
2869
|
-
if (end < text.length && code >= 0xd800 && code <= 0xdbff) end += 1
|
|
3117
|
+
// R3 (1.6.5): budget the ESCAPED frame, not the raw bytes — the shell
|
|
3118
|
+
// counts UTF-16 units of the decoded JSON, and `"`/`\`/control chars
|
|
3119
|
+
// inflate well past any raw-byte budget.
|
|
3120
|
+
const chunks = splitForBridge(text, name, id)
|
|
3121
|
+
for (let i = 0; i < chunks.length; i += 1) {
|
|
2870
3122
|
bridge.postMessage(JSON.stringify({
|
|
2871
|
-
t: 'save', id, name, data:
|
|
3123
|
+
t: 'save', id, name, data: chunks[i], last: i === chunks.length - 1,
|
|
2872
3124
|
}))
|
|
2873
|
-
i = end
|
|
2874
3125
|
}
|
|
2875
|
-
return true
|
|
3126
|
+
return { sent: true, chunks: chunks.length }
|
|
2876
3127
|
} catch {
|
|
2877
|
-
return false
|
|
3128
|
+
return { sent: false, chunks: 0 }
|
|
2878
3129
|
}
|
|
2879
3130
|
}
|
|
2880
3131
|
|
|
@@ -2887,10 +3138,23 @@ window.__ModuleLoader__.load({
|
|
|
2887
3138
|
}
|
|
2888
3139
|
const text = JSON.stringify(result.export, null, 2) + '\n'
|
|
2889
3140
|
const fileName = 'dsh-instruction-memory-' + new Date().toISOString().slice(0, 10) + '.json'
|
|
2890
|
-
//
|
|
2891
|
-
//
|
|
2892
|
-
|
|
2893
|
-
|
|
3141
|
+
// A5 (1.6.4): an export carries EVERY set and every persona, while the
|
|
3142
|
+
// panel itself deliberately shows only the active set. Say what left
|
|
3143
|
+
// the machine instead of implying "your current view".
|
|
3144
|
+
const exported = result.export.data !== null && typeof result.export.data === 'object'
|
|
3145
|
+
? result.export.data
|
|
3146
|
+
: {}
|
|
3147
|
+
const counts = {
|
|
3148
|
+
sets: Array.isArray(exported.sets) ? exported.sets.length : 1,
|
|
3149
|
+
entries: Array.isArray(exported.entries) ? exported.entries.length : 0,
|
|
3150
|
+
profiles: Array.isArray(exported.profiles) ? exported.profiles.length : 0,
|
|
3151
|
+
}
|
|
3152
|
+
// Inside DSH Go the app CAN write the file — but only if the shell
|
|
3153
|
+
// implements the `save` message, which the stock build does not.
|
|
3154
|
+
const bridge = await sendToAppBridge(text, fileName)
|
|
3155
|
+
if (bridge.sent) {
|
|
3156
|
+
stageExportFallback(text)
|
|
3157
|
+
setNotice(t('export.bridgeHint', { chunks: bridge.chunks, sets: counts.sets, entries: counts.entries, profiles: counts.profiles }))
|
|
2894
3158
|
return
|
|
2895
3159
|
}
|
|
2896
3160
|
/**
|
|
@@ -2902,8 +3166,8 @@ window.__ModuleLoader__.load({
|
|
|
2902
3166
|
* route unconditionally.
|
|
2903
3167
|
*/
|
|
2904
3168
|
if (isAndroidWebView() || typeof URL === 'undefined' || typeof URL.createObjectURL !== 'function') {
|
|
2905
|
-
|
|
2906
|
-
setNotice(t('export.
|
|
3169
|
+
stageExportFallback(text)
|
|
3170
|
+
setNotice(t('export.androidHint', { sets: counts.sets, entries: counts.entries, profiles: counts.profiles }))
|
|
2907
3171
|
return
|
|
2908
3172
|
}
|
|
2909
3173
|
const blob = new Blob([text], { type: 'application/json' })
|
|
@@ -2919,7 +3183,7 @@ window.__ModuleLoader__.load({
|
|
|
2919
3183
|
// The desktop host cannot confirm this landed: its download handler
|
|
2920
3184
|
// only claims `#dsh-download=` URLs, and a blob click is Chromium's
|
|
2921
3185
|
// business. Offer the guaranteed route and say what was attempted.
|
|
2922
|
-
|
|
3186
|
+
stageExportFallback(text)
|
|
2923
3187
|
setNotice(t('export.desktopHint'))
|
|
2924
3188
|
} else {
|
|
2925
3189
|
setNotice(t('export.saved'))
|
|
@@ -2929,7 +3193,7 @@ window.__ModuleLoader__.load({
|
|
|
2929
3193
|
}
|
|
2930
3194
|
}
|
|
2931
3195
|
|
|
2932
|
-
async function handleImportFile(file) {
|
|
3196
|
+
async function handleImportFile(file, confirmed) {
|
|
2933
3197
|
try {
|
|
2934
3198
|
const verdict = importSizeVerdict(
|
|
2935
3199
|
file && typeof file.size === 'number' ? file.size : NaN,
|
|
@@ -2954,14 +3218,11 @@ window.__ModuleLoader__.load({
|
|
|
2954
3218
|
setError(t('import.notJson', { detail: String(err && err.message ? err.message : err) }))
|
|
2955
3219
|
return
|
|
2956
3220
|
}
|
|
2957
|
-
// 1.6.1:
|
|
2958
|
-
//
|
|
2959
|
-
//
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
const askImport = askConfirm(t('import.confirm'))
|
|
2963
|
-
if (askImport !== CONFIRM_YES) {
|
|
2964
|
-
if (askImport === CONFIRM_UNAVAILABLE) setError(t('confirm.unavailable'))
|
|
3221
|
+
// 1.6.1: import asks before merging; 1.6.5's contract runs the action
|
|
3222
|
+
// from inside confirmThen, so the replay carries `confirmed` and skips
|
|
3223
|
+
// this block rather than re-asking.
|
|
3224
|
+
if (confirmed !== true) {
|
|
3225
|
+
confirmThen(t('import.confirm'), () => handleImportFile(file, true))
|
|
2965
3226
|
return
|
|
2966
3227
|
}
|
|
2967
3228
|
await send('import-data', { payload, baseRev: revOf(), confirm: true })
|
|
@@ -3117,7 +3378,13 @@ window.__ModuleLoader__.load({
|
|
|
3117
3378
|
// with this draft — a silent overwrite. Ask first, and only
|
|
3118
3379
|
// then retry against the rev we just learned.
|
|
3119
3380
|
if (result.conflict === true && !allowOverwrite) {
|
|
3120
|
-
|
|
3381
|
+
// S6 (1.6.5): the 'allow' fallback meant "no dialog → treat
|
|
3382
|
+
// as yes", so on a WebView a CRLF-less confirm refusal turned
|
|
3383
|
+
// into a silent overwrite of the other window's edit. This is
|
|
3384
|
+
// the only allow-fallback that can destroy someone else's
|
|
3385
|
+
// work, so it asks properly like every durable action.
|
|
3386
|
+
const overwrite = () => commit(revOf(), true)
|
|
3387
|
+
confirmThen(t('editor.conflictOverwrite'), overwrite)
|
|
3121
3388
|
}
|
|
3122
3389
|
})
|
|
3123
3390
|
}
|
|
@@ -3310,7 +3577,14 @@ window.__ModuleLoader__.load({
|
|
|
3310
3577
|
disabled: busy,
|
|
3311
3578
|
onClick: toggleFeedback,
|
|
3312
3579
|
}, feedbackOpen ? t('feedback.hide') : t('feedback.show'))),
|
|
3313
|
-
|
|
3580
|
+
// A10 (1.6.4): the feedback path needs SMTP credentials from the
|
|
3581
|
+
// environment (`DSH_INSTRUCTION_MEMORY_FEEDBACK_SMTP_HOST` and the
|
|
3582
|
+
// secret), and the DSH Go shell clears the environment. The button
|
|
3583
|
+
// would fail every time, so on the phone it explains itself instead.
|
|
3584
|
+
feedbackOpen && isAndroidWebView()
|
|
3585
|
+
? h('div', { className: 'im-meta', key: 'feedback-mobile' }, t('feedback.mobileUnavailable'))
|
|
3586
|
+
: null,
|
|
3587
|
+
feedbackOpen && !isAndroidWebView()
|
|
3314
3588
|
? h('div', { className: 'im-feedback-form' },
|
|
3315
3589
|
h('div', { className: 'im-meta' }, t('feedback.intro')),
|
|
3316
3590
|
h('div', { className: 'im-grid2' },
|
|
@@ -3666,7 +3940,15 @@ window.__ModuleLoader__.load({
|
|
|
3666
3940
|
h('button', {
|
|
3667
3941
|
className: 'im-btn im-btn-danger',
|
|
3668
3942
|
disabled: busy,
|
|
3669
|
-
onClick: () =>
|
|
3943
|
+
onClick: () => {
|
|
3944
|
+
const ids = liveSelected()
|
|
3945
|
+
if (ids.length === 0) {
|
|
3946
|
+
setError(t('batch.noneSelected'))
|
|
3947
|
+
return
|
|
3948
|
+
}
|
|
3949
|
+
confirmThen(t('batch.confirmDelete', { count: ids.length }),
|
|
3950
|
+
() => { void doBatch('delete', undefined, ids) })
|
|
3951
|
+
},
|
|
3670
3952
|
}, t('batch.delete')),
|
|
3671
3953
|
h('button', { className: 'im-btn', disabled: busy, onClick: exitBatch }, t('batch.exit')))
|
|
3672
3954
|
: null,
|
|
@@ -3855,7 +4137,7 @@ window.__ModuleLoader__.load({
|
|
|
3855
4137
|
onFocus: (ev) => { if (typeof ev.target.select === 'function') ev.target.select() },
|
|
3856
4138
|
}),
|
|
3857
4139
|
h('div', { className: 'im-row-wrap' },
|
|
3858
|
-
h('button', { className: 'im-btn', onClick: () =>
|
|
4140
|
+
h('button', { className: 'im-btn', onClick: () => clearExportFallback() }, t('export.fallbackClose'))))
|
|
3859
4141
|
: null,
|
|
3860
4142
|
isAndroidWebView()
|
|
3861
4143
|
? h('div', { className: 'im-meta' }, t('import.webviewHint'))
|
|
@@ -3999,6 +4281,38 @@ window.__ModuleLoader__.load({
|
|
|
3999
4281
|
: null),
|
|
4000
4282
|
liveDown ? h('div', { className: 'im-meta', role: 'status' }, t('sse.down')) : null,
|
|
4001
4283
|
error !== '' ? h('div', { className: 'im-err', role: 'alert' }, error) : null,
|
|
4284
|
+
// 1.6.4: the in-panel confirmation. Rendered where the banners are, so a
|
|
4285
|
+
// parked destructive action is impossible to miss and the list it
|
|
4286
|
+
// refers to sits right below it.
|
|
4287
|
+
pendingConfirm !== null
|
|
4288
|
+
? h('div', { className: 'im-confirm', role: 'group', key: 'pending-confirm' },
|
|
4289
|
+
h('div', { className: 'im-confirm-text' }, pendingConfirm.message),
|
|
4290
|
+
h('div', { className: 'im-row' },
|
|
4291
|
+
h('button', {
|
|
4292
|
+
className: 'im-btn im-btn-primary',
|
|
4293
|
+
// R2 (1.6.5): one activation, one action. A double tap (or a
|
|
4294
|
+
// touch jitter) used to run the replayed handler twice; the
|
|
4295
|
+
// delete survived on the host's idempotency, but import/restore
|
|
4296
|
+
// were never verified. `busy` also blocks it here, so an action
|
|
4297
|
+
// that is already in flight cannot be re-fired from the bar.
|
|
4298
|
+
disabled: busy === true || confirmFiringRef.current === true,
|
|
4299
|
+
onClick: () => {
|
|
4300
|
+
const pending = pendingConfirm
|
|
4301
|
+
if (pending === null || confirmFiringRef.current === true) return
|
|
4302
|
+
// Stays true until the NEXT question is parked: a second
|
|
4303
|
+
// activation in the same tick (double tap, touch jitter) must
|
|
4304
|
+
// not run the action twice. The delete survived on the host's
|
|
4305
|
+
// idempotency; import/restore never had that guarantee.
|
|
4306
|
+
confirmFiringRef.current = true
|
|
4307
|
+
setPendingConfirm(null)
|
|
4308
|
+
void pending.action()
|
|
4309
|
+
},
|
|
4310
|
+
}, t('confirm.yes')),
|
|
4311
|
+
h('button', {
|
|
4312
|
+
className: 'im-btn',
|
|
4313
|
+
onClick: () => setPendingConfirm(null),
|
|
4314
|
+
}, t('confirm.no'))))
|
|
4315
|
+
: null,
|
|
4002
4316
|
error === '' && notice !== '' ? h('div', { className: 'im-ok', role: 'status', 'aria-live': 'polite' }, notice) : null,
|
|
4003
4317
|
error === '' && notice === '' && storage.error ? h('div', { className: 'im-err', role: 'alert' }, storage.error) : null,
|
|
4004
4318
|
undo !== null ? h('div', { className: 'im-undo', key: 'undo' },
|
|
@@ -4165,32 +4479,51 @@ window.__ModuleLoader__.load({
|
|
|
4165
4479
|
: h('button', {
|
|
4166
4480
|
className: 'im-btn',
|
|
4167
4481
|
disabled: busy,
|
|
4168
|
-
onClick: () => {
|
|
4482
|
+
onClick: () => {
|
|
4483
|
+
// A6 (1.6.5): the editor is an early return, so a confirmation
|
|
4484
|
+
// parked in the list view would be invisible while the draft
|
|
4485
|
+
// is open — the action would hang until the editor closed.
|
|
4486
|
+
setPendingConfirm(null)
|
|
4487
|
+
setDraft(cloneEntry(entry))
|
|
4488
|
+
setProfileDraft(null)
|
|
4489
|
+
setError('')
|
|
4490
|
+
},
|
|
4169
4491
|
}, t('entry.edit')),
|
|
4170
4492
|
batchMode
|
|
4171
4493
|
? null
|
|
4172
4494
|
: h('button', {
|
|
4173
4495
|
className: 'im-btn im-btn-danger',
|
|
4174
4496
|
disabled: busy,
|
|
4497
|
+
// A bare "删除" is ambiguous for a screen reader (and for any
|
|
4498
|
+
// test) when the page also has set delete, snapshot delete and
|
|
4499
|
+
// batch delete. Name the target.
|
|
4500
|
+
'aria-label': t('entry.deleteAria', {
|
|
4501
|
+
title: entry.title !== '' ? entry.title : t('entry.untitled'),
|
|
4502
|
+
}),
|
|
4503
|
+
title: t('entry.deleteAria', {
|
|
4504
|
+
title: entry.title !== '' ? entry.title : t('entry.untitled'),
|
|
4505
|
+
}),
|
|
4175
4506
|
onClick: () => {
|
|
4176
|
-
//
|
|
4177
|
-
// the
|
|
4178
|
-
//
|
|
4179
|
-
//
|
|
4180
|
-
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4507
|
+
// R1 (1.6.5): the action lives AFTER the guard, never only
|
|
4508
|
+
// inside the replay closure. `confirmThen` returns false on
|
|
4509
|
+
// "a real dialog said yes" and does NOT run `run` itself, so
|
|
4510
|
+
// the 1.6.4 shape (action only in the closure, nothing after
|
|
4511
|
+
// the `if`) made this button a silent no-op on desktop and in
|
|
4512
|
+
// the browser. The lint gate now rejects that shape.
|
|
4513
|
+
const removeEntry = () => {
|
|
4514
|
+
// Keep the full entry for the undo bar; the POST response
|
|
4515
|
+
// (not this closure) is what confirms the deletion happened.
|
|
4516
|
+
setUndo(null)
|
|
4517
|
+
send('delete-entry', { id: entry.id, baseRev: revOf() }).then((result) => {
|
|
4518
|
+
if (result === null || result.ok !== true) return
|
|
4519
|
+
setUndo({ entry, expires: Date.now() + UNDO_TTL_MS })
|
|
4520
|
+
})
|
|
4186
4521
|
}
|
|
4187
|
-
//
|
|
4188
|
-
//
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
setUndo({ entry, expires: Date.now() + UNDO_TTL_MS })
|
|
4193
|
-
})
|
|
4522
|
+
// 1.6.5 contract: confirmThen runs this action itself (or parks
|
|
4523
|
+
// it), so there is exactly one execution site.
|
|
4524
|
+
confirmThen(t('entry.confirmDelete', {
|
|
4525
|
+
title: entry.title !== '' ? entry.title : t('entry.untitled'),
|
|
4526
|
+
}), removeEntry)
|
|
4194
4527
|
},
|
|
4195
4528
|
}, t('entry.delete'))),
|
|
4196
4529
|
h(EntryBody, { text: entry.content, key: 'body' }),
|
|
@@ -4490,6 +4823,16 @@ window.__ModuleLoader__.load({
|
|
|
4490
4823
|
exports.__sameSnapshot = sameSnapshot
|
|
4491
4824
|
exports.__confirmDiscard = confirmDiscard
|
|
4492
4825
|
exports.__askConfirm = askConfirm
|
|
4826
|
+
// 1.6.4 mobile-shape hooks: the byte splitter and the "can a dialog be
|
|
4827
|
+
// believed here?" probe are the two pieces that decide whether a phone can
|
|
4828
|
+
// export and delete at all, so they are pinned in Node rather than left to
|
|
4829
|
+
// a device nobody has on the build machine.
|
|
4830
|
+
exports.__splitByBytes = splitByBytes
|
|
4831
|
+
exports.__splitForBridge = splitForBridge
|
|
4832
|
+
exports.__confirmDialogsAreTrustworthy = confirmDialogsAreTrustworthy
|
|
4833
|
+
exports.__islandChunkBytes = ISLAND_CHUNK_BYTES
|
|
4834
|
+
exports.__islandFrameLimit = ISLAND_FRAME_LIMIT
|
|
4835
|
+
exports.__hasIslandBridge = hasIslandBridge
|
|
4493
4836
|
exports.__importSizeVerdict = importSizeVerdict
|
|
4494
4837
|
exports.__nextBudgetText = nextBudgetText
|
|
4495
4838
|
exports.__budgetMeter = budgetMeter
|
package/lib/index.js
CHANGED
|
@@ -6431,7 +6431,9 @@ export function apply(ctx, deps = {}) {
|
|
|
6431
6431
|
+ '"设置页发出的请求"与"本机任意进程伪造的请求"——Origin、Sec-Fetch-Site、Cookie 都由请求方自带,'
|
|
6432
6432
|
+ '因此写操作默认停用(读操作不受影响,设置页仍可打开查看)。'
|
|
6433
6433
|
+ '若这是单用户设备且你接受该风险,设置 ' + ALLOW_UNGUARDED_WRITES_ENV + '=1 后重启;'
|
|
6434
|
-
+ '更稳妥的做法是让宿主提供 connection 服务,或用 ' + REQUIRE_AUTH_FENCE_ENV + '=1 关闭整条路由。'
|
|
6434
|
+
+ '更稳妥的做法是让宿主提供 connection 服务,或用 ' + REQUIRE_AUTH_FENCE_ENV + '=1 关闭整条路由。'
|
|
6435
|
+
+ '(若是 DSH Go 手机版:App 内的宿主进程不继承外部环境变量,这个开关在手机上设不了——请在 App 内重启或升级 App,'
|
|
6436
|
+
+ '或让 App 提供一个带该开关的构建。)',
|
|
6435
6437
|
}
|
|
6436
6438
|
}
|
|
6437
6439
|
const origin = typeof head.origin === 'string' ? head.origin.trim() : ''
|
|
@@ -6677,6 +6679,15 @@ export function apply(ctx, deps = {}) {
|
|
|
6677
6679
|
}
|
|
6678
6680
|
connectionGate = service
|
|
6679
6681
|
logDebug('connection fence attached; the route now requires an authenticated browser session')
|
|
6682
|
+
// A8 (1.6.4): the panel renders `security.writeGate` from the snapshot, and
|
|
6683
|
+
// a subscriber that already took one frame would keep showing "writes are
|
|
6684
|
+
// disabled" long after the fence arrived. The route registers before the
|
|
6685
|
+
// service on some profiles, so this edge has to push.
|
|
6686
|
+
try {
|
|
6687
|
+
pushSnapshot()
|
|
6688
|
+
} catch (err) {
|
|
6689
|
+
logDebug('snapshot push after fence attach failed: ' + describeErrorSafe(err))
|
|
6690
|
+
}
|
|
6680
6691
|
scope.effect(() => () => {
|
|
6681
6692
|
if (connectionGate !== service) return
|
|
6682
6693
|
connectionGate = null
|
|
@@ -6686,6 +6697,11 @@ export function apply(ctx, deps = {}) {
|
|
|
6686
6697
|
// authentication downgrade, and `snapshot.security.authFence` now shows
|
|
6687
6698
|
// it for as long as it lasts.
|
|
6688
6699
|
logInfo('connection fence detached while the plugin stayed mounted; the route falls back to the loopback-only rule until the service is published again')
|
|
6700
|
+
try {
|
|
6701
|
+
pushSnapshot()
|
|
6702
|
+
} catch (err) {
|
|
6703
|
+
logDebug('snapshot push after fence detach failed: ' + describeErrorSafe(err))
|
|
6704
|
+
}
|
|
6689
6705
|
})
|
|
6690
6706
|
})
|
|
6691
6707
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-instruction-memory",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.5",
|
|
4
4
|
"description": "User-only instruction memory for DSH: long-term instructions maintained in the settings UI and auto-injected into every conversation — the plugin registers no model-facing tool, so the model has no in-plugin write path (a same-permission process can still edit the file directly). 指令记忆:只由用户在设置页维护的长期指令,自动注入此后每轮对话;插件不注册任何面向模型的工具,模型没有插件内的写入口。",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"author": "huangpeiyan",
|
|
66
66
|
"scripts": {
|
|
67
67
|
"lint": "node lint.mjs",
|
|
68
|
-
"test": "node
|
|
68
|
+
"test": "node test-all.mjs",
|
|
69
69
|
"prepublishOnly": "node check-metadata.mjs && npm test",
|
|
70
70
|
"smoke:hosts": "node live-host-smoke.mjs"
|
|
71
71
|
},
|