@dsh-mobile/mobile-remote 0.0.0-stage → 3.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1273 -0
- package/CONTRIBUTING.md +59 -0
- package/FAQ.md +115 -0
- package/LICENSE +21 -0
- package/README.md +293 -2
- package/cordis.patch.yml +22 -0
- package/docs/00-/345/274/200/345/217/221/346/200/273/347/272/262.md +121 -0
- package/docs/01-PRD.md +148 -0
- package/docs/02-architecture.md +249 -0
- package/docs/03-api.md +882 -0
- package/docs/04-security.md +109 -0
- package/docs/05-test-cases.md +376 -0
- package/docs/06-install-run.md +349 -0
- package/docs/07-user-manual.md +92 -0
- package/docs/08-/346/211/251/345/261/225/345/274/200/345/217/221/346/214/207/345/215/227.md +86 -0
- package/docs/09-compatibility.md +201 -0
- package/docs/10-remote-access-and-launch-plan.md +216 -0
- package/docs/11-remote-relay-guide.md +82 -0
- package/docs/APP-ENCRYPTION-DESCRIPTION.md +50 -0
- package/docs/APP-ENCRYPTION-DESCRIPTION.pdf +0 -0
- package/docs/ARCHITECTURE-CURRENT.md +229 -0
- package/docs/AUDIT-2026-11-node.md +181 -0
- package/docs/AUDIT-2026-11.md +167 -0
- package/docs/BRAND-ASSETS.md +142 -0
- package/docs/BUILD-ENVIRONMENT.md +180 -0
- package/docs/FEATURE-PARITY.md +195 -0
- package/docs/PRIVACY-POLICY.en.md +143 -0
- package/docs/PRIVACY-POLICY.md +143 -0
- package/docs/REA-UNDERSTANDING.md +246 -0
- package/docs/STORE-LAUNCH.md +278 -0
- package/docs/STORE-LISTING.md +150 -0
- package/docs/SUPPORT.md +43 -0
- package/docs/TERMS-OF-SERVICE.en.md +70 -0
- package/docs/TERMS-OF-SERVICE.md +70 -0
- package/docs/screenshots/01-home.png +0 -0
- package/docs/screenshots/02-notifications.png +0 -0
- package/docs/screenshots/03-sessions.png +0 -0
- package/docs/screenshots/04-chat.png +0 -0
- package/docs/screenshots/05-settings.png +0 -0
- package/docs/screenshots/06-new-session.png +0 -0
- package/docs/screenshots/07-connect.png +0 -0
- package/docs/screenshots/pgy-appstore.jpg +0 -0
- package/docs/screenshots/pgy-mobile-app.jpg +0 -0
- package/docs/screenshots/pgy-pc-client.jpg +0 -0
- package/lib/account-usage-query.js +278 -0
- package/lib/account-usage.js +145 -0
- package/lib/api-helpers.js +333 -0
- package/lib/auto-config.js +107 -0
- package/lib/client.js +586 -0
- package/lib/config.js +211 -0
- package/lib/git-read-bundled-provider.js +255 -0
- package/lib/git-read-service.js +322 -0
- package/lib/host-compat.js +133 -0
- package/lib/http-util.js +69 -0
- package/lib/index.js +5729 -0
- package/lib/push.js +73 -0
- package/lib/rate-limit.js +46 -0
- package/lib/relay/connector.js +300 -0
- package/lib/relay/crypto.js +117 -0
- package/lib/relay/devices.js +138 -0
- package/lib/relay/identity.js +60 -0
- package/lib/relay/mux.js +411 -0
- package/lib/relay/noise.js +178 -0
- package/lib/relay/pairing.js +64 -0
- package/lib/relay/phone.js +114 -0
- package/lib/relay/serve.js +105 -0
- package/lib/rpc-adapter.js +88 -0
- package/lib/session-list.js +77 -0
- package/lib/session-title-cache.js +123 -0
- package/lib/session-title-refresh.js +261 -0
- package/lib/timeline.js +476 -0
- package/lib/turn-outline.js +289 -0
- package/package.json +62 -4
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
# DSH Mobile 当前架构
|
|
2
|
+
|
|
3
|
+
这份文档把当前代码实际形成的边界固定下来,作为补 iOS、脚本和 CI 时的改动基线。它刻意保留现有 Android 业务架构和 `/m/api` 协议;平台差异只在需要原生能力的接缝处理,避免为了双端适配重写已经稳定的状态、路由和事件模型。
|
|
4
|
+
|
|
5
|
+
> 记录时间:2026-11-01(Asia/Shanghai)
|
|
6
|
+
> 基线:插件 `3.2.4`,Flutter App `3.2.4+31`
|
|
7
|
+
|
|
8
|
+
## 1. 总体数据流
|
|
9
|
+
|
|
10
|
+
```text
|
|
11
|
+
Flutter App(iOS / Android)
|
|
12
|
+
│ HTTP JSON + SSE
|
|
13
|
+
▼
|
|
14
|
+
dsh-mobile-remote 插件(/m/api、SSE、认证、通知、LAN bridge)
|
|
15
|
+
│ ctx.get / ctx.inject / session event
|
|
16
|
+
▼
|
|
17
|
+
DSH 宿主服务(agents / sessions / llm / permission / workspaces / goals)
|
|
18
|
+
│
|
|
19
|
+
▼
|
|
20
|
+
DSH agent loop 与会话持久化(电脑端唯一真源)
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
手机端不复制会话数据库。App 启动时先恢复连接配置和 UI 缓存,再从 `/api/bootstrap` 获取服务端状态;持续状态由 `/api/events` SSE 和按需 REST 补拉共同维护。
|
|
24
|
+
|
|
25
|
+
## 2. Flutter 入口和页面结构
|
|
26
|
+
|
|
27
|
+
### 2.1 入口
|
|
28
|
+
|
|
29
|
+
- `lib/main.dart`:`WidgetsFlutterBinding.ensureInitialized()`、日志初始化、API 配置加载、App 偏好加载、主题和全局 `AppStore` 创建、通知/保活/宠物初始化,以及连接页和主导航。
|
|
30
|
+
- 全局 `AppStore store = AppStore()`:使用 `ChangeNotifier`,由页面通过构造参数或全局入口读取。
|
|
31
|
+
- `rootNavigatorKey`:允许通知、桌面宠物面板动作和冷启动动作跨页面跳转。
|
|
32
|
+
|
|
33
|
+
### 2.2 页面
|
|
34
|
+
|
|
35
|
+
| 区域 | 实现 | 责任 |
|
|
36
|
+
|---|---|---|
|
|
37
|
+
| 连接 | `main.dart`、`scan_screen.dart` | 扫码、手动地址/token、探测、保存、进入主界面 |
|
|
38
|
+
| 首页 | `screens/home_screen.dart` | 欢迎语、最近会话、新建会话、输入配置、皮肤背景/角色 |
|
|
39
|
+
| 会话 | `screens/sessions_screen.dart`、`session_list.dart` | 会话列表、刷新、工作区归属、归档和打开 |
|
|
40
|
+
| 对话 | `screens/chat_screen.dart` | 历史、流式消息、Markdown、工具状态、队列、任务、审批/问询、文件/Git/命令 |
|
|
41
|
+
| 通知 | `screens/notifications_screen.dart` | 未读、已读、删除、跳转会话 |
|
|
42
|
+
| 设置 | `screens/settings_screen.dart` | 连接、主题、语言、外观、模型/权限/provider、用量、诊断、后台能力 |
|
|
43
|
+
| 用量 | `screens/usage_screen.dart` | 余额、账户来源和配额 |
|
|
44
|
+
| Provider | `screens/providers_screen.dart` | 真实 provider 列表、编辑、探测、保存和删除密钥 |
|
|
45
|
+
| 文件 | `screens/session_files_screen.dart`、`session_files_controller.dart` | 工作区文件、下载、预览、Markdown/源码、解码 |
|
|
46
|
+
| 工具弹层 | `screens/session_tools_sheet.dart`、`git_browser_sheet.dart`、`sheets.dart` | jobs、子代理、目标、Git、目录和新建会话选择 |
|
|
47
|
+
|
|
48
|
+
现有页面和业务不应因为 iOS 工程补齐而删除。需要平台差异时,页面依赖平台能力抽象,不直接调用 Android MethodChannel。
|
|
49
|
+
|
|
50
|
+
## 3. 状态管理
|
|
51
|
+
|
|
52
|
+
`lib/store.dart` 的 `AppStore extends ChangeNotifier` 负责:
|
|
53
|
+
|
|
54
|
+
- 当前 `sessionId`、会话列表、catalog、session config、actions、workspace;
|
|
55
|
+
- 当前 agent/session 状态映射,规范为 `idle | running`;
|
|
56
|
+
- 连接状态、SSE subscription、看门狗、重试退避和地址轮换;
|
|
57
|
+
- pending questions、approvals、队列镜像、任务和上下文窗口;
|
|
58
|
+
- 通知列表、未读数和 `AttentionLedger`;
|
|
59
|
+
- 主题、语言、皮肤、图标、推理显示和聊天行为偏好;
|
|
60
|
+
- 会话列表缓存、草稿、思维链折叠覆盖和 Git tab 状态。
|
|
61
|
+
|
|
62
|
+
状态来源按优先级分为:
|
|
63
|
+
|
|
64
|
+
1. 服务端 bootstrap 的快照;
|
|
65
|
+
2. SSE 的增量事件和 pending frame;
|
|
66
|
+
3. 事件缺失或恢复期间的 REST 补拉;
|
|
67
|
+
4. 仅用于首屏体验的本地偏好/列表缓存。
|
|
68
|
+
|
|
69
|
+
AppStore 不应把本地缓存当作服务端事实;重连和回前台必须重新从服务端收敛状态。
|
|
70
|
+
|
|
71
|
+
## 4. API 层
|
|
72
|
+
|
|
73
|
+
`lib/api.dart` 是唯一的 Flutter HTTP/SSE 客户端,负责:
|
|
74
|
+
|
|
75
|
+
- 连接配置、path 标准化、候选 URL 合并和轮换;
|
|
76
|
+
- `X-Mobile-Token` 认证头;
|
|
77
|
+
- JSON 请求、错误码和 HTTP status 映射到 `ApiException`;
|
|
78
|
+
- SSE 文本分帧、JSON 解码、心跳和连接建立超时;
|
|
79
|
+
- 会话、历史、消息、审批、通知、文件、工作区、Git、模型、provider、用量和诊断端点;
|
|
80
|
+
- 文件下载的流式响应、Range/ETag 能力和图片附件 LRU。
|
|
81
|
+
|
|
82
|
+
协议面保持 `/m/api` 和服务端既有字段,不引入新状态管理框架或第二套 API 客户端。iOS 适配首先复用该层,只有平台保存、通知和文件交互需要新增能力实现。
|
|
83
|
+
|
|
84
|
+
## 5. 事件流
|
|
85
|
+
|
|
86
|
+
### 5.1 App 侧 SSE 分发
|
|
87
|
+
|
|
88
|
+
`store.dart` 的事件入口把顶层帧分发为:
|
|
89
|
+
|
|
90
|
+
- `hello`:能力、连接、地址、会话、通知、目录和 catch-up;
|
|
91
|
+
- `git/changed`:Git 数据变化;
|
|
92
|
+
- `notifications/changed`:通知列表变化;
|
|
93
|
+
- `mobile/notify`:插件通知;
|
|
94
|
+
- `mobile/frame`:问询/审批 requested/resolved;
|
|
95
|
+
- `mobile/queue`:队列镜像;
|
|
96
|
+
- `session/context`:上下文窗口;
|
|
97
|
+
- `session/jobs`:任务和进度;
|
|
98
|
+
- `session/event`:可见会话事件;
|
|
99
|
+
- `agent/status`:agent/session 运行状态。
|
|
100
|
+
|
|
101
|
+
`session/event` 不使用过窄白名单;`assistant/chunk`、`assistant/live-chunk`、`tool/call`、`tool/result` 等由聊天页根据事件类型解释。`turn/end` 触发通知判据。
|
|
102
|
+
|
|
103
|
+
### 5.2 服务端事件桥
|
|
104
|
+
|
|
105
|
+
`lib/index.js` 在宿主 session/event 上订阅并生成移动端摘要,通过 SSE 广播;问询、审批和队列等瞬态帧通过移动桥回放。服务端负责认证、连接上限、心跳和广播失败隔离。桌面版 webserver 强制回环时,LAN bridge 在插件内监听外部地址并只转发移动路由。
|
|
106
|
+
|
|
107
|
+
## 6. 连接和重连
|
|
108
|
+
|
|
109
|
+
当前流程:
|
|
110
|
+
|
|
111
|
+
1. 手动输入或扫码得到 base URL、path、token。
|
|
112
|
+
2. 请求 bootstrap,收集服务端返回的地址候选。
|
|
113
|
+
3. 建立 SSE 并处理 `hello`。
|
|
114
|
+
4. 事件增量更新 AppStore;聊天页按 seq/消息身份去重。
|
|
115
|
+
5. SSE 超时、心跳看门狗或网络错误触发重建。
|
|
116
|
+
6. 连续失败后按候选地址轮换,指数退避。
|
|
117
|
+
7. 回到前台或恢复连接后重新 bootstrap,并按当前会话补拉 history/pending 状态。
|
|
118
|
+
|
|
119
|
+
这个模型必须保留;iOS 不能用“Flutter 进程一直后台运行”代替后台通知。iOS 回前台时要把服务端状态作为权威重新同步。
|
|
120
|
+
|
|
121
|
+
## 7. 通知和审批
|
|
122
|
+
|
|
123
|
+
### 7.1 App 内
|
|
124
|
+
|
|
125
|
+
- `mobile/notify`、`notifications/changed` 和 `turn/end` 更新通知中心。
|
|
126
|
+
- `attention.dart` 用 `kind|sessionId|approvalId/rpcId` 形成稳定身份,负责去重、展示决策和精确撤销。
|
|
127
|
+
- 进入对应会话后,App 内卡片和横幅承担即时提醒。
|
|
128
|
+
|
|
129
|
+
### 7.2 系统通知
|
|
130
|
+
|
|
131
|
+
- `local_notifications.dart` 使用 `flutter_local_notifications`;当前初始化逻辑只对 Android 生效。
|
|
132
|
+
- iOS 需要在同一抽象后补 `UNUserNotificationCenter` 权限、分类动作、badge、点击 payload 和冷启动会话跳转。
|
|
133
|
+
- 服务端既有 `pushUrls` 作为 App 被挂起或离线时的推送桥;不能把 Android 前台服务行为直接承诺为 iOS 行为。
|
|
134
|
+
|
|
135
|
+
## 8. 本地存储
|
|
136
|
+
|
|
137
|
+
### 8.1 SharedPreferences
|
|
138
|
+
|
|
139
|
+
普通偏好和连接配置目前由 `SharedPreferences` 保存:
|
|
140
|
+
|
|
141
|
+
- 地址/path/token/候选地址/插件版本;
|
|
142
|
+
- 当前会话、会话列表缓存、工作区;
|
|
143
|
+
- 主题、语言、皮肤、图标、Git tab、动作顺序;
|
|
144
|
+
- 推理显示、余额预警、宠物设置、后台保活开关。
|
|
145
|
+
|
|
146
|
+
其中 token 是敏感凭据,当前实现仍在普通偏好存储;上架前必须用 Android Keystore + iOS Keychain 的 Flutter 封装迁移,且保留普通偏好只存非敏感配置。
|
|
147
|
+
|
|
148
|
+
### 8.2 内存状态和文件
|
|
149
|
+
|
|
150
|
+
- 草稿、队列镜像、pending 问询/审批是进程内状态。
|
|
151
|
+
- 会话列表和偏好可恢复,不能替代服务端事实。
|
|
152
|
+
- 图片附件有进程内 LRU。
|
|
153
|
+
- 日志由 `AppLog` 统一入口记录,需在发布前确认 token、二维码和会话敏感内容不会写入日志或截图。
|
|
154
|
+
|
|
155
|
+
## 9. 原生平台桥接
|
|
156
|
+
|
|
157
|
+
### 9.1 当前 Android 通道
|
|
158
|
+
|
|
159
|
+
| 通道 | 原生功能 | 当前实现 |
|
|
160
|
+
|---|---|---|
|
|
161
|
+
| `dsh/floating` | 悬浮宠物、overlay 权限、余额/配置同步、面板动作 | `MainActivity.kt` + `FloatingBubbleService.kt` |
|
|
162
|
+
| `dsh/files` | 文件选择、保存、打开、分享、文本解码 | `MainActivity.kt` |
|
|
163
|
+
| `dsh/app_icon` | activity-alias 图标切换/同步 | `MainActivity.kt` + Manifest |
|
|
164
|
+
| `dsh/keepalive` | 前台服务保活、状态、心跳、电池设置 | `MainActivity.kt` + `KeepAliveService.kt` |
|
|
165
|
+
|
|
166
|
+
`main.dart` 和 `settings_screen.dart` 当前存在启动/初始化时直接触发这些通道的路径;iOS 补齐前必须集中成平台能力接口,非支持能力返回明确状态,不允许页面收到 `MissingPluginException`。
|
|
167
|
+
|
|
168
|
+
### 9.2 iOS 需要补齐
|
|
169
|
+
|
|
170
|
+
- Flutter Runner 工程、AppDelegate/Scene 配置、Info.plist 和 AppIcon。
|
|
171
|
+
- Bundle Identifier、最低 iOS 版本、网络和相机/照片/通知用途说明。
|
|
172
|
+
- Keychain 安全存储实现。
|
|
173
|
+
- `UNUserNotificationCenter` 通知权限、分类、点击和 badge。
|
|
174
|
+
- `UIDocumentPickerViewController` 或等价文件选择;文件保存到 Files/分享面板;文件打开和文本解码。
|
|
175
|
+
- scene phase 生命周期:回前台 bootstrap、SSE 重建和 pending 事件补拉。
|
|
176
|
+
- 设备网络权限和 ATS:只加实际需要的最小配置,不默认放开公网不安全 HTTP。
|
|
177
|
+
- 固定 App Icon;若以后支持 alternate icons,独立实现并更新矩阵。
|
|
178
|
+
|
|
179
|
+
Android 专属的悬浮宠物、前台服务和 activity-alias 不直接移植到 iOS。它们对应的产品结果分别是 App 内状态入口、APNs/回前台补拉、固定图标。
|
|
180
|
+
|
|
181
|
+
## 10. Android 构建和发布结构
|
|
182
|
+
|
|
183
|
+
- `dsh-mobile-app/android/settings.gradle.kts`:Flutter Gradle loader、AGP、Kotlin。
|
|
184
|
+
- `android/app/build.gradle.kts`:namespace `com.dsh.remote`、Java/Kotlin 17、desugaring、release keystore 读取、无 key 时 release 构建失败(`DSH_ALLOW_DEBUG_SIGNING=1` 显式放行 debug 签名)。
|
|
185
|
+
- `android/app/src/main/AndroidManifest.xml`:相机、网络、通知、悬浮窗、前台服务、8 个图标 alias 和两个 service。
|
|
186
|
+
- `assets/`:Logo、图标、皮肤、桌面宠物和动画资源。
|
|
187
|
+
- `pubspec.yaml`:Flutter 依赖和资产声明。
|
|
188
|
+
|
|
189
|
+
当前 `key.properties`、release keystore、Flutter local.properties 都不存在。正式商店构建必须由用户保管 keystore 或由 CI Secrets 注入,不能写入仓库。
|
|
190
|
+
|
|
191
|
+
## 11. iOS 构建和发布结构(目标)
|
|
192
|
+
|
|
193
|
+
补齐后目标结构:
|
|
194
|
+
|
|
195
|
+
```text
|
|
196
|
+
dsh-mobile-app/ios/
|
|
197
|
+
Runner/
|
|
198
|
+
AppDelegate.swift
|
|
199
|
+
Info.plist
|
|
200
|
+
Assets.xcassets/AppIcon.appiconset/
|
|
201
|
+
LaunchScreen.storyboard
|
|
202
|
+
Runner.xcodeproj/
|
|
203
|
+
Runner.xcworkspace/
|
|
204
|
+
Podfile
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
构建分工:
|
|
208
|
+
|
|
209
|
+
- Windows:Dart 开发、Node/Flutter 测试(安装工具链后)、Android debug/release 无签名构建。
|
|
210
|
+
- macOS GitHub runner:Flutter pub get、分析、测试、`flutter build ios --no-codesign`;有证书时再执行签名/IPA。
|
|
211
|
+
- 用户账号边界:Apple Developer/App Store Connect、Google Play 服务账号、签名证书、provisioning profile、keystore 都不由仓库生成或提交。
|
|
212
|
+
|
|
213
|
+
## 12. 当前不改变的架构决策
|
|
214
|
+
|
|
215
|
+
1. 保留 Node.js 插件作为 DSH 电脑端真实协议实现。
|
|
216
|
+
2. 保留 Flutter `ChangeNotifier` 状态模型和现有页面结构。
|
|
217
|
+
3. 保留 HTTP JSON + SSE,不把协议改成 WebSocket。
|
|
218
|
+
4. 保留服务端会话唯一真源,不在 App 侧做第二份会话数据库。
|
|
219
|
+
5. 保留 Android 全部现有入口;平台差异写进矩阵并做等价替代。
|
|
220
|
+
6. 不用假 API、写死响应、静态截图或 Demo 数据绕过真实链路。
|
|
221
|
+
|
|
222
|
+
## 13. 本轮实现状态更新(2026-11-01)
|
|
223
|
+
|
|
224
|
+
- iOS Runner 已由 Flutter 3.47.9 官方生成并纳入工程;Bundle ID 与 Android applicationId 统一为 `com.mrdayone.dshmobile`。
|
|
225
|
+
- iOS 原生桥接位于 `ios/Runner/AppDelegate.swift`:文件选择/导出/预览/分享/文本解码走 UIKit;Android overlay、前台服务和动态图标在 iOS 明确返回不支持,Flutter 页面提供状态说明和 App 内替代路径。
|
|
226
|
+
- `flutter_secure_storage 11.2.0` 已成为 token 的安全存储边界;连接地址和 UI 偏好仍由 SharedPreferences 保存。
|
|
227
|
+
- `flutter_local_notifications` 已为 iOS 配置 Darwin 初始化、权限请求和通知展示;iOS 后台依赖系统通知与回前台补拉,不依赖常驻 Flutter 进程。
|
|
228
|
+
- iOS `Info.plist` 已声明相机、照片、本地网络和通知用途;ATS 仅开启 `NSAllowsLocalNetworking`。
|
|
229
|
+
- 当前可在 Windows 验证 Dart 分析、测试和配置契约;Swift/Xcode 编译和设备行为必须在 macOS runner 完成。
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
> **出处与复核状态**:本文是委托子任务对 Node 侧(`lib/`、`relay/`、`tools/`、`test/`、CI)的审计原文,作为 `AUDIT-2026-11.md` 的附录。
|
|
2
|
+
> 主审计者已独立复核:全量 `node --test` 为 490 项 / 482 通过 / 0 失败 / 8 跳过;D1 的三个请求目标确实都会让 `new URL()` 抛 `ERR_INVALID_URL`;
|
|
3
|
+
> 12 个脚本确已删除。其余条目(D2–D5、C1、S1–S9)以其自带的先红后绿测试为证据,本轮没有逐条重做。
|
|
4
|
+
> 文中「someone is editing the Flutter app」指的是主审计者在同一仓库里的 Flutter 工作;pbxproj 的 CRLF→LF 变动内容为零(`git diff --ignore-cr-at-eol` 为空,只是换行符),来源是本轮某次 Flutter/Xcode 构建工具运行(没能确定是哪一次;之后单独跑 `xcodebuild` 不会改它),已无损还原为与 HEAD 逐字节一致。
|
|
5
|
+
|
|
6
|
+
# Node side audit and cleanup - DSH Mobile (`@dsh-mobile/mobile-remote` 3.2.4)
|
|
7
|
+
|
|
8
|
+
Repo: `/Users/Apple/Downloads/Liux/DSH mobile` (branch main, nothing committed/staged/stashed). Node v24.21.0.
|
|
9
|
+
Everything below is derived from source and from commands run in this session. Raw outputs are in
|
|
10
|
+
`<scratchpad>/node-audit/`.
|
|
11
|
+
|
|
12
|
+
## 0. Numbers
|
|
13
|
+
|
|
14
|
+
| | before | after |
|
|
15
|
+
|---|---|---|
|
|
16
|
+
| `wc -l lib/index.js` | 7693 | **5730** (-1963, -25.5%) |
|
|
17
|
+
| new modules under `lib/` | - | 11 files, 2086 lines (config, turn-outline, timeline, session-list, host-compat, api-helpers, account-usage-query, push, rate-limit, http-util, rpc-adapter) |
|
|
18
|
+
| `node --test test/*.js test/*.mjs` | 426 tests / 418 pass / 0 fail / 8 skip | **490 tests / 481 pass / 1 fail / 8 skip** (see note) |
|
|
19
|
+
| same, with `ws` available (`RELAY_TEST_WS=...`) | 6 skips become passes | 487 pass / 1 fail / 2 skip |
|
|
20
|
+
| `tools/` | 17 files | 5 files (12 superseded scripts deleted) |
|
|
21
|
+
| `node --check` on every tracked .js/.mjs outside `dsh-mobile-app` | 73 files OK | 83 files OK (incl. new) |
|
|
22
|
+
| `npm audit --omit=dev` | - | 0 vulnerabilities |
|
|
23
|
+
|
|
24
|
+
Note on the 1 failure: `test/store-config.test.mjs` "set-app-id ... 保留 pbxproj 的 CRLF" asserts that
|
|
25
|
+
`dsh-mobile-app/ios/Runner.xcodeproj/project.pbxproj` is CRLF. HEAD has CRLF; the working tree copy is now LF
|
|
26
|
+
(`git diff --stat` shows 669 lines changed in that one file) because someone is editing the Flutter app concurrently.
|
|
27
|
+
It passed in my earlier full runs (435/427/0/8) and is unrelated to any Node file. Restore CRLF in that file (or normalise
|
|
28
|
+
via `.gitattributes`) and the suite is 490/482/0/8.
|
|
29
|
+
|
|
30
|
+
Flake observed once: in one of roughly ten full runs `test/git-read-service.test.js` failed at file level after ~2.1 s (479 tests counted instead of 490). The same file passes standalone (21/21, 15 s) and the very next full run was 490/481/1/8. `lib/git-read-service.js` and that test were not touched by this work; cause not identified (git-heavy test under load). Worth watching.
|
|
31
|
+
|
|
32
|
+
The 8 skips, verified: 6 are `test/relay-node-server.test.mjs` real-socket tests, skipped because `ws` is not installed
|
|
33
|
+
(it is only in `relay/package.json`, and CI never installed it). With `RELAY_TEST_WS=<local node_modules>`
|
|
34
|
+
(an existing local `ws` 8.21.0, no network) all 6 pass. The other 2 are `test/store-config.test.mjs` keystore tests, skipped
|
|
35
|
+
because `keytool` is a macOS stub with no Java runtime here (`java -version` -> "Unable to locate a Java Runtime").
|
|
36
|
+
|
|
37
|
+
## 1. Methods and commands (what was actually run)
|
|
38
|
+
|
|
39
|
+
1. **Syntax**: `git ls-files '*.js' '*.mjs' ':!dsh-mobile-app' | while read f; do node --check "$f"; done` -> 73/73 OK at start; 83/83 OK at end.
|
|
40
|
+
2. **Dead code**
|
|
41
|
+
- `node-audit/deadcode.mjs`: extracts every declaration (any depth) in `lib/` + `relay/` (1388 at start, 1470 at end) and counts
|
|
42
|
+
word-boundary references across code, tests, tools, docs, CI. Start: 2 zero-reference declarations (`settingsReadsByDescribe`, `QR_IMAGE`),
|
|
43
|
+
20 exports referenced only inside their own file. End: 0 zero-reference, 9 own-file-only exports (list in section 6).
|
|
44
|
+
- Scope-aware pass (the regex script cannot see shadowing): `tsc --allowJs --checkJs --noEmit --noUnusedLocals --noUnusedParameters`
|
|
45
|
+
(TypeScript from `<local node_modules>`, tsconfig in `node-audit/tsconfig.json`), filtering TS6133/6192/6196/6198/6199
|
|
46
|
+
and TS2304/2552 (undefined names). Start: unused `AUTO` import, shadowing never-read `CORPUS_FRESH_MS`, never-read `now` and `sessions`
|
|
47
|
+
locals, `QR_IMAGE`. After every extraction the same run was used to find missing/unused imports. End state: only two false positives
|
|
48
|
+
(`require` factory parameter in `lib/client.js`, `env` parameter in the Cloudflare worker) and the pre-existing `Buffer` global note.
|
|
49
|
+
3. **Risky-pattern greps** (`lib/`, `lib/relay/`, `relay/`): `JSON.parse` (17 production sites in lib/ + relay/; all inside try/catch or the hub's serialised queue, results shape-checked),
|
|
50
|
+
`catch {}` (own script `node-audit/emptycatch.mjs`: 60 empty catch blocks at HEAD, 56 carry an explanatory comment, 4 are bare; reviewed individually, one finding S5),
|
|
51
|
+
`.catch(() => {})`, `eval|new Function` (none in shipped code), `==`/`!=` (only `== null` idiom), `Math.random` (3 uses: reconnect jitter, ping nonce,
|
|
52
|
+
notification id suffix - none secret), `new URL(` (see D1), `setTimeout|setInterval|addEventListener|.on(` against the dispose function,
|
|
53
|
+
unbounded `Map`/`Set`/arrays per request or connection, `body.xxx` vs `body?.xxx` after `readJson`, token comparison (`timingSafeEqual` everywhere,
|
|
54
|
+
sha256-normalised), `homedir()` vs `DSH_HOME`.
|
|
55
|
+
4. **Dependencies**: `npm ls --all` / `--omit=dev --depth=0`: 5 peer packages + `qrcode` all imported (`grep -rE "from \"[^./n]..."`); `ws` imported by
|
|
56
|
+
`relay/run.js` only; `dsh-codex-connect` is a dynamic optional import. `npm audit --omit=dev` -> ENOLOCK in the repo (no lockfile by design), so the hidden
|
|
57
|
+
`node_modules/.package-lock.json` was transplanted into a temp dir with the same `package.json` and audited there: **0 vulnerabilities** (this contacted the
|
|
58
|
+
npm registry, which is the only network use).
|
|
59
|
+
5. **Package manifest**: `npm pack --dry-run --json`: `exports` targets (`lib/index.js`, `lib/client.js`, `package.json`) exist; `files` covers all new modules via `lib`; tarball is
|
|
60
|
+
3.4 MB packed / 4.5 MB unpacked, of which 3.2 MB is `docs/screenshots` shipped because `"docs"` is in `files` (recommendation R6); `relay/` is not shipped (separate deployable);
|
|
61
|
+
`lib/relay/phone.js` (114 lines, test-only phone reference) is shipped.
|
|
62
|
+
6. **CI** (`.github/workflows/ci.yml`): claimed "Syntax check" only ran `lib/*.js` (missed `lib/relay/*.js`, `relay/**`, `tools`, `test`); the 6 relay socket tests always skipped in CI
|
|
63
|
+
(no `ws`). Fixed (section 3, C1). Node 22.x only, `engines` says >=20.3 (Node 20 never tested; zstd tests need >=22.15) - noted, not changed.
|
|
64
|
+
7. **Read line by line with an attacker's eye**: `lib/index.js` token/cookie auth (`tokenMatches`, `cookieToken`, `authorized`), `hostnameOf`/`hostAllowed`/`trustedHosts`, `crossSiteBlocked`,
|
|
65
|
+
rate limiter, `clientIpOf` + `CLIENT_IP_HEADER` nonce, `relayPeerOf` + `RELAY_PEER_HEADER`, `localDesktopGate`, `serveQr`, `/qr-config`, `/relay/*`, `/dev/approval-test`, `handleApi` preamble,
|
|
66
|
+
`readBody`/`readJson`/`sendJson`, SSE `connect`/`broadcast`/heartbeat, LAN bridge (request-target parsing, path allow-list, header stripping/forwarding, timeouts, dispose), file browse/download/upload,
|
|
67
|
+
`/send` receipts + held queue, dispose function; `relay/hub.js`, `relay/node-server.js`, `relay/cloudflare/worker.js`, `lib/relay/{noise,mux,connector,pairing,devices,identity,serve,crypto,phone}.js`.
|
|
68
|
+
Conclusions on the parts that held up: LAN bridge excludes `/api/qr-config` exactly and normalises the path before forwarding (dot-segments and `%2e` collapse before the allow-list check); bridge deletes
|
|
69
|
+
client-supplied `x-dsh-mobile-client-ip` and `x-dsh-relay-peer` and writes its own; `localDesktopGate` is independent of the relay path allow-list (three layers); relay replayer drops cookie/token/proxy/origin headers and rejects any
|
|
70
|
+
path that normalisation would change; hub auth binds room = SHA-256(pubkey)[:16] with a per-connection nonce; pre-verification guests are capped at 4 frames / 8 KiB.
|
|
71
|
+
8. **Tools scripts**: ran every offline-capable script (9) and attempted the live ones (6, all die with ECONNREFUSED, as expected without a DSH host) - results in section 4.
|
|
72
|
+
9. **Reproduction discipline**: each defect below has a test that was run red against the unfixed code (output seen), then the fix, then green. The held-queue test was additionally re-run with the fix line neutralised to confirm it still fails.
|
|
73
|
+
|
|
74
|
+
## 2. Verified defects (reproduced, fixed)
|
|
75
|
+
|
|
76
|
+
| # | file:line (at HEAD) | severity | repro test (red before, green after) | fix |
|
|
77
|
+
|---|---|---|---|---|
|
|
78
|
+
| D1 | `relay/node-server.js:74` (`new URL(req.url, base)` in the `'upgrade'` listener) | **High** (unauthenticated remote crash of the public relay process) | `test/relay-node-server.test.mjs`: "升级请求的目标不合法:只断开该连接,不抛异常(直接触发 upgrade 事件)" and "...真实 TCP 上发出后中继仍然存活并继续服务" (stub `WebSocketServer`, so they run in CI without `ws`). Raw TCP `GET http://[ HTTP/1.1` + `Upgrade: websocket` makes Node's parser accept the target, `new URL` throws `ERR_INVALID_URL` inside an event listener = `uncaughtException`; `//[` and `http://:99999999/` do the same, `http://a b/` is rejected by the parser. `relay/run.js` installs no handler, so the process exits. | parse inside try/catch, `socket.destroy()` on failure |
|
|
79
|
+
| D2 | `lib/index.js:3089` `readJson` + ~40 `body.xxx` call sites (e.g. `/directories`, `/sessions/new`, `/llm-providers`, `/files/...`) | Low (authenticated client gets `500 internal` + a handler-error log instead of 4xx) | `test/api-json-body-shape.test.mjs`: POST `/m/api/directories` with body `null` -> expected 400 `invalid-name`, got 500 | `JSON.parse(...) ?? {}` in `readJson` (`null` and `{}` are already equivalent at every `body?.x` site; only the previously-throwing sites change) |
|
|
80
|
+
| D3 | `lib/index.js` state files: `READ_FILE`, `HELD_FILE`, `RECEIPT_FILE`, `ACTIVITY_FILE`, `MESSAGE_TIME_FILE`, `session-titles.json` (11 `join(homedir(), ".dsh", "mobile-remote", ...)` sites) | Medium (multi-instance isolation: two hosts with different `DSH_HOME` share the held-queue / send-receipt / activity files; token and relay identity already honoured `DSH_HOME`, contradicting the promise in `auto-config.js`; docs/06 even records an "isolated DSH_HOME" test run) | `test/state-dir.test.mjs`: with `DSH_HOME=<tmp>` the activity file must appear in `<tmp>/mobile-remote/`, got "目录不存在"; second test pins the default (`~/.dsh/mobile-remote`) unchanged | single `STATE_DIR = mobileRemoteStateDir()` in `apply`. **Behaviour note**: users who set `DSH_HOME` will start with empty read/held/receipt/activity state once after upgrading (default users: identical paths) |
|
|
81
|
+
| D4 | `lib/index.js:2284` `releaseHeld` | Medium (duplicate user message) | `test/held-queue-release.test.mjs` "图片排队消息:投递尚未返回时再来一次 idle,不得把同一条消息再投递一次": 2 `session.prompt` calls instead of 1. Image release is async (up to 120 s) and the entry is only dropped on success; both the `agent/status idle` event and the 30 s sweep re-enter `releaseHeld` meanwhile | in-flight id set `imageReleasesInFlight`; entries in flight are skipped; cleared on settle |
|
|
82
|
+
| D5 | `lib/relay/connector.js:43-51` | Low / latent (not reachable from production code, which calls `start()` once) | `test/relay-state.test.mjs` "连接器:stop() 之后再 start(),设备撤销仍然会踢掉该设备的在线会话": after `stop();start()` the revoke listener count was 0 | `start()` re-subscribes (`unsubscribe ??=`), `stop()` nulls it |
|
|
83
|
+
| C1 | `.github/workflows/ci.yml` | Medium (process: false confidence) | n/a (workflow change; YAML read by eye, cannot run Actions here) | syntax check over all tracked JS/MJS outside the app; `npm install --prefix relay` + `RELAY_TEST_WS` so the 6 socket tests run |
|
|
84
|
+
|
|
85
|
+
Dead code found by the scope-aware pass, removed (proof = zero reads, see section 3).
|
|
86
|
+
|
|
87
|
+
## 3. Removed code and proof it was dead
|
|
88
|
+
|
|
89
|
+
| item | proof |
|
|
90
|
+
|---|---|
|
|
91
|
+
| `AUTO` import in `lib/index.js` | tsc TS6133; the only uses in repo are `lib/auto-config.js` (definition) and tests that import it from `auto-config.js` directly |
|
|
92
|
+
| local `const CORPUS_FRESH_MS` inside `apply()` | tsc TS6133 (never read); it only shadowed the exported module constant that `planMessageTimePrune` actually uses (same value); comment re-pointed |
|
|
93
|
+
| `const now = Date.now()` in `listPersistedSubagents` | tsc TS6133; the comment describing it referred to an upstream fallback map that no longer exists |
|
|
94
|
+
| `const sessions = ctx.get("sessions")` in `/catalog` | tsc TS6133; `ctx.get` is a pure lookup |
|
|
95
|
+
| `export const settingsReadsByDescribe` | 0 references in lib, test, tools, relay, docs, README, CHANGELOG (deadcode.mjs); not a host-injected name (plain helper) |
|
|
96
|
+
| `var QR_IMAGE = "/m/qr.png"` in `lib/client.js` | tsc TS6133; `client-relay-panel` and `package-manifest` tests pass |
|
|
97
|
+
| 12 scripts in `tools/` | section 4 |
|
|
98
|
+
|
|
99
|
+
## 4. `tools/` scripts
|
|
100
|
+
|
|
101
|
+
Kept: `e2e-check.mjs` (live smoke, referenced by CONTRIBUTING.md:27 and docs/05), `timeline-contract-check.mjs` (offline, 125 asserts, passes; now run by `test/tools-offline-checks.test.mjs`),
|
|
102
|
+
`verify-no-model-session.mjs` (live acceptance for v3.1.0 default-model fallback; needs a real model, not covered by any test; unsure -> kept), `make-upload-keystore.sh`, `set-app-id.sh`.
|
|
103
|
+
|
|
104
|
+
Deleted (plain `rm`, not staged). Rule applied: delete only if the assertions now live in `test/` (ported verbatim, run green) or the script is a replica/obsolete. Each script was run first.
|
|
105
|
+
|
|
106
|
+
| script | result when run | disposition |
|
|
107
|
+
|---|---|---|
|
|
108
|
+
| `account-usage-check.mjs` | 15/15 pass | ported verbatim -> `test/account-usage.test.mjs` (15) |
|
|
109
|
+
| `account-usage-adversarial-check.mjs` | 19/19 pass | ported verbatim -> `test/account-usage-adversarial.test.mjs` (19) |
|
|
110
|
+
| `hotfix07-unit-check.mjs` | 14/14 pass (tried hard-coded `C:/Users/30623/...` first) | ported -> `test/pure-helpers.test.mjs` |
|
|
111
|
+
| `wsl-path-check.mjs` | 8/8 pass (same hard-coded paths) | ported -> `test/pure-helpers.test.mjs` |
|
|
112
|
+
| `verify-image-sniff.mjs` | pass, but extracts `sniffImageType` from `index.js` source with a regex + `new Function` (would break on any refactor) | ported -> `test/pure-helpers.test.mjs` against the real export |
|
|
113
|
+
| `verify-413-precheck.mjs`, `verify-64k-fix.mjs` | pass, but they test their own **copy** of `readBody`/`sendJson`, never the plugin | replaced by real-plugin tests in `test/send-contract.test.mjs` (declared >64 MB -> 413 JSON over a raw socket; `readBody` limit/close behaviour) |
|
|
114
|
+
| `hotfix05-check.mjs` | needs live DSH (ECONNREFUSED) | its non-live asserts (bad requestId 400, receipt 404/400, >64 MB 413) and its LIVE idempotency asserts (text + image, same requestId -> same result, delivered once) are now in `test/send-contract.test.mjs` against a fake agents service |
|
|
115
|
+
| `verify-issue14-p0.mjs` | **34 pass / 3 FAIL**: B1, B4, B5 stale since `pushApprovalGraceMs` (default 5 s) defers the approval push; the script waited 60 ms. Nobody noticed. | ported with `pushApprovalGraceMs: 0` -> `test/issue14-p0-mock-host.test.mjs`; all 37 asserts green (this is the only coverage of todo summaries, `sourceKind`, `/todos`, replay-frame shape, push-test bookkeeping) |
|
|
116
|
+
| (new) | - | `test/push-channels.test.mjs` pins the ntfy request shape (root POST + `topic`) and the serverchan/bark/wecom/generic bodies, previously asserted only for ntfy and only inside the stale script |
|
|
117
|
+
| `verify-issue14-live.mjs` | needs live DSH + a human killing the phone app | superseded by the mock-host test above (same assertions, no human) |
|
|
118
|
+
| `phase1-check.mjs` | needs live DSH on hard-coded port 56343 | no assertions (prints responses), v2 development scratch -> deleted |
|
|
119
|
+
| `push-test.mjs` | needs live DSH | 14 lines, no assertions, sends a real prompt -> deleted |
|
|
120
|
+
|
|
121
|
+
### Dangling references created by the deletions (for the parent to fix; I did not edit docs)
|
|
122
|
+
|
|
123
|
+
- `README.md:282` - "tools/ 验证脚本(e2e-check / phase1-check / push-test)" -> should list `e2e-check / timeline-contract-check / verify-no-model-session`.
|
|
124
|
+
- `docs/05-test-cases.md:188` - `node tools/wsl-path-check.mjs(normalizeServerPath,8/8)` -> `node --test test/pure-helpers.test.mjs`.
|
|
125
|
+
- `CHANGELOG.md` lines 347, 384, 477, 495, 519, 570, 676, 734, 742, 765 name deleted scripts (account-usage-check, verify-issue14-p0/live, wsl-path-check, hotfix05/07 ...). They are release history; leave as is, optionally add a "tools consolidated into test/" note to the next entry.
|
|
126
|
+
- Also stale because of the refactor: `docs/08-扩展开发指南.md:49` says to add a push format "在 `lib/index.js` 的 `pushToChannel`" -> now `lib/push.js` (`pushToChannel`, the per-format branches). `README.md:279` describes `lib/index.js` as holding everything; list the new modules.
|
|
127
|
+
|
|
128
|
+
## 5. Refactor map (`lib/index.js` -> new modules; verbatim moves, wire formats and log strings untouched)
|
|
129
|
+
|
|
130
|
+
Public surface check: all 51 exports of HEAD's `lib/index.js` are still exported (re-exported via `export { ... } from`), except the removed dead `settingsReadsByDescribe`; no new exports on `index.js` (verified by importing and diffing the name sets). `package.json` `exports`/`files` unchanged.
|
|
131
|
+
|
|
132
|
+
| new module (lines) | contents | HEAD `lib/index.js` lines |
|
|
133
|
+
|---|---|---|
|
|
134
|
+
| `lib/config.js` (214) | `Config` schema, `DEFAULT_ENUMERATION_BUDGET_MS`, `DEFAULT_WARM_UP_TITLE_BUDGET_MS` | 44-253 |
|
|
135
|
+
| `lib/turn-outline.js` (290) | event-detail error classification, `TURN_OUTLINE_*`, `createTurnOutlineQueue`, `raceWithDeadline`, `turnOutlineCapabilityOf`, `clampTurnOutline`, `turnOutlineStateOf` | 255-293, 326-587 |
|
|
136
|
+
| `lib/timeline.js` (477) | `EVENT_TIMELINE_CAPABILITIES`, replay/live/detail type sets, `isTimelineRecord` & co, `blocksToText`, image/file/reasoning projections, `sniffImageType`, `summarizeEvent`, `detailEventFor` | 295-308, 589-690, 976-985, 1087-1426 |
|
|
137
|
+
| `lib/session-list.js` (78) | `sessionListSortKey`, `compareSessionsForList`, `latestMessageTimeOf`, `CORPUS_FRESH_MS`, `planMessageTimePrune` | 691-757 |
|
|
138
|
+
| `lib/host-compat.js` (134) | generation probes (ADR 0017): `jobsNeedsSessionId`, `wireStreamTakesControl`, `hostPeerSource`, `createInProcessPeer`, `readSettingsSection(Strict)`, `jobsCallerFor`, `capabilityState` | 816-955 |
|
|
139
|
+
| `lib/api-helpers.js` (334) | `redactPathText`, `requestHeaderText`, `clampText`, MIME map, `mapBounded`, `orderQrAddresses`, `receiptExpired`, `pruneReceiptMap`, `normalizeServerPath`, `validateQuestionAnswers`, `classifyFetchFailure`, `safeFailureReason`, `requestAbort`, `FILE_RANGE_CAPABILITIES`, `parseByteRange`, `ifNoneMatch` | 266-270, 310-324, 759-820, 957-1085, 1510-1556, 1775-1783, ~6165-6194 |
|
|
140
|
+
| `lib/account-usage-query.js` (279) | `deriveKeyRef`, credential resolution, Codex/OpenCode/DeepSeek upstream queries, `queryAccountUsage` | 1440-1773 |
|
|
141
|
+
| `lib/push.js` (74) | `ntfyPublish`, `pushToChannel(logger, ...)` (was a closure over `ctx.logger`; `apply` keeps a one-line wrapper) | 1428-1438, 2855-2896 |
|
|
142
|
+
| `lib/rate-limit.js` (47) | `createLoginRateLimiter` (the 10/60 s bucket logic, 512-source cap) | 3005-3039 |
|
|
143
|
+
| `lib/http-util.js` (70) | `guardRes`, `sendJson`, `sendError` (was `error`), `readBody`, `requireGet`, `requirePost` | 3041-3059, 3060-3080, 3100-3114, 3631-3637 |
|
|
144
|
+
| `lib/rpc-adapter.js` (89) | `RPC_ENDPOINT_RENAMES`, `RPC_PAYLOAD_ADAPTER`, `RPC_STREAM_METHODS`, `projectionOf`, `rpcError` | 3356-3407, 3507-3535 |
|
|
145
|
+
|
|
146
|
+
**Left in `index.js` and why**: `handleApi` (~2800 lines) and everything it closes over (title refresher/enumeration single-flight, notification and done-timer state machine, held queue/receipts persistence, approval/question bridge,
|
|
147
|
+
LAN bridge, SSE connection set, gateway peer cache). These share ~60 mutable closure variables; extracting them would mean threading a context object through hundreds of references or rewriting control flow, which the brief rules out.
|
|
148
|
+
The LAN bridge (about 170 lines) is the most separable next candidate if wanted (needs `lanBridgeListening`, `announceConnection`, the two nonce tokens, `ctx.webServer`, `guardRes`). Five state files use the same load/persist/debounce shape and could share a
|
|
149
|
+
helper, but that is a rewrite, not a move.
|
|
150
|
+
|
|
151
|
+
## 6. Suspected / not reproduced / not fixed (and why)
|
|
152
|
+
|
|
153
|
+
- **S1** `notifyAskDeferred` (`lib/index.js` ~2775): the 5 s `unref`'d grace timer is not cleared on dispose; after unload it can still call `pushNotification`/`pushSend`. Harmless to the event loop, but sends a push from a disposed plugin. Needs an approval request followed by dispose within 5 s; not reproduced.
|
|
154
|
+
- **S2** `/send` receipt: between `sendReceipts.set(key, in-progress)` and the `try {` (~4186-4217) `createUserMessage`/content assembly could throw -> outer handler 500 and the receipt stays `in-progress` for 15 min, so retries get 409 `receipt-pending`. I could not make `createUserMessage` throw with validated inputs; kept as a note.
|
|
155
|
+
- **S3** `heldQueue` has no per-session cap and `persistHeld()` rewrites the whole queue (including base64 images) on every mutation. Authenticated clients only. A cap needs a new error response = wire change, so not applied. Same for `/send` allowing 64 MB bodies x `maxConnections`.
|
|
156
|
+
- **S4** Error detail leakage: `POST /directories` (`mkdir-failed`), `/files/upload` (`write-failed`), `/actions/:id/invoke` (`action-failed`) return raw `err.message` (contains absolute host paths) while the S7 policy redacts everywhere else. Redacting changes the detail text on the wire -> reported, not applied.
|
|
157
|
+
- **S5** `/llm-providers` `removeKey`: `credentials.unset(...).catch(() => {})` swallows failures; response is 200 with `keyConfigured:false` even if the key was not removed. Whether "not found" must be tolerated depends on the credentials service semantics; changing it alters responses.
|
|
158
|
+
- **S6** `relay/node-server.js` `ipOf` with `TRUST_PROXY=1` takes the **leftmost** `X-Forwarded-For` entry, which is client-controlled behind proxies that append (nginx `$proxy_add_x_forwarded_for`); the per-IP limiter is then bypassable and `IpLimiter.hits` can grow (sweep only runs above 10 000 entries and only removes expired keys). Default (`TRUST_PROXY` off) uses the socket address and is fine. Fix = use the right-most trusted hop; changes limiter keying for multi-proxy chains -> reported only.
|
|
159
|
+
- **S7** `lanBridgeSockets` entries are removed on the first response `close` of a socket, so keep-alive sockets stop being tracked after one request. The bridge forces `connection: close` except for SSE, so only SSE sockets would be missed at unload (the SSE `res`/upstream are destroyed by `connections` handling).
|
|
160
|
+
- **S8** `lib/relay/mux.js` `request()` never removes its `abort` listener from a long-lived caller signal (client side exists only in the test phone reference).
|
|
161
|
+
- **S9** `trustedHosts()` calls `os.networkInterfaces()` per request (cost, not correctness). `DROP_RESPONSE_HOOK` (`DSH_MOBILE_REMOTE_DROP_RESPONSE=1`) is a test hook compiled into the production `/send` path.
|
|
162
|
+
- 9 exports used only inside their own file, kept as API/test seams: `OTP_TTL_MS`, `MAX_DEVICES` (devices.js), `MAX_HEAD_BYTES` (mux.js), `PROTOCOL_NAME`, `CipherState` (noise.js), `PhoneSession` (phone.js), `DEFAULT_LIMITS`, `unb64u` (hub.js). Unsure -> kept.
|
|
163
|
+
|
|
164
|
+
## 7. Recommended doc edits (not applied)
|
|
165
|
+
|
|
166
|
+
- R1 `docs/10-remote-access-and-launch-plan.md:68` says `Noise_IK_25519_ChaChaPoly_BLAKE2s`; the implementation, vectors and `relay/README.md` use `..._SHA256`.
|
|
167
|
+
- R2 Document that all plugin state (token, relay identity, read/held/receipt/activity/title files) lives under `$DSH_HOME/mobile-remote` (default `~/.dsh/mobile-remote`): `docs/04-security.md:73,88`, `README.md:87`, `docs/02-architecture.md:189`, `cordis.patch.yml` comment. Mention the one-time empty state for `DSH_HOME` users (D3).
|
|
168
|
+
- R3 `README.md:282`, `docs/05-test-cases.md:188`, `docs/08-扩展开发指南.md:49`, `README.md:279`: see section 4.
|
|
169
|
+
- R4 `relay/README.md`: `TRUST_PROXY=1` trusts the first `X-Forwarded-For` hop; only enable behind a proxy that overwrites the header (S6).
|
|
170
|
+
- R5 `CONTRIBUTING.md:27` "插件改动:跑 `tools/e2e-check.mjs`" - also say `node --test test/*.js test/*.mjs` (what CI runs); note that `RELAY_TEST_WS` / `npm install --prefix relay` is needed to run the relay socket tests locally.
|
|
171
|
+
- R6 `package.json` `files`: `"docs"` ships 3.2 MB of screenshots in the npm tarball; consider `"!docs/screenshots"` (not changed here). `lib/relay/phone.js` is test-only code in the tarball.
|
|
172
|
+
- R7 CHANGELOG entry for the next release: D1 (relay crash), D2, D3 (`DSH_HOME` state dir), D4 (duplicate held image), D5, tools consolidated into `test/`, `lib/index.js` split.
|
|
173
|
+
- R8 Environment: the CRLF->LF change in `dsh-mobile-app/ios/Runner.xcodeproj/project.pbxproj` breaks `test/store-config.test.mjs` (set-app-id); restore CRLF or add a `.gitattributes` rule.
|
|
174
|
+
|
|
175
|
+
## 8. Files changed (all unstaged)
|
|
176
|
+
|
|
177
|
+
Modified: `.github/workflows/ci.yml`, `lib/index.js`, `lib/client.js`, `lib/relay/connector.js`, `relay/node-server.js`, `test/relay-node-server.test.mjs`, `test/relay-state.test.mjs`.
|
|
178
|
+
Added: `lib/{config,turn-outline,timeline,session-list,host-compat,api-helpers,account-usage-query,push,rate-limit,http-util,rpc-adapter}.js`;
|
|
179
|
+
`test/{account-usage,account-usage-adversarial,api-json-body-shape,held-queue-release,issue14-p0-mock-host,pure-helpers,push-channels,send-contract,state-dir,tools-offline-checks}.test.mjs`, `test/helpers/send-harness.mjs`.
|
|
180
|
+
Deleted: the 12 `tools/*` scripts in section 4.
|
|
181
|
+
Not touched: `dsh-mobile-app/**`, `docs/**`, `README.md`, `CHANGELOG.md`, `package.json`.
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# 2026-11 全面审查、重构与重设计记录
|
|
2
|
+
|
|
3
|
+
> 记录时间:2026-11-01(Asia/Shanghai) 基线:插件 `3.2.4`,App `3.2.4+31`,`main` @ `35cb329`
|
|
4
|
+
>
|
|
5
|
+
> 这份文档只记**做过什么、怎么验证的、哪里没验证**。每条结论都能用文末「复核命令」重新跑出来;
|
|
6
|
+
> 没有跑过的东西明确写成「未验证」。
|
|
7
|
+
|
|
8
|
+
## 1. 项目现状(从源码与配置核实)
|
|
9
|
+
|
|
10
|
+
| 方面 | 现状 | 依据 |
|
|
11
|
+
|---|---|---|
|
|
12
|
+
| 形态 | Node 插件(`/m/api` 路由、SSE、认证、推送、LAN 桥)+ Flutter App(Android/iOS 同一套 Dart)+ 可独立部署的 E2E 加密中继 | `package.json`、`dsh-mobile-app/pubspec.yaml`、`relay/` |
|
|
13
|
+
| 版本 | 插件 3.2.4 / App 3.2.4+31 | 两处清单一致 |
|
|
14
|
+
| Android | 已发布过;本环境没有 Android SDK,**原生代码与资源未在本轮编译** | `docs/BUILD-ENVIRONMENT.md`、本环境 `flutter doctor` 无 SDK |
|
|
15
|
+
| iOS | 模拟器 Debug 可构建、可运行(本轮实机验证:演示模式、聊天、审批全流程);**未签名、未真机、未上架** | 本轮 `xcodebuild` + 模拟器 |
|
|
16
|
+
| 远程访问(中继) | 协议/服务端/客户端/测试齐全,**首发版本入口默认隐藏**(`Features.remoteAccess=false`) | `lib/features.dart`、`docs/STORE-LAUNCH.md` §3c |
|
|
17
|
+
| 上架缺口 | 签名密钥与 App Store Connect/Play 控制台事项必须由发布者完成;商标名使用与关系声明见 STORE-LAUNCH §1 | `docs/STORE-LAUNCH.md` |
|
|
18
|
+
| 知识产权 | 此前:App 图标与首页使用 DeepSeek 鲸鱼标识,吉祥物素材来自第三方仓库、出处不清——文档自己标注「未解决」。本轮已删除鲸鱼标识与旧吉祥物;默认图标/标志/首页角色改用项目方提供的两张图片,其余为代码绘制,见 §7(**两张图片的授权仍由项目方确认**) | `docs/STORE-LAUNCH.md`(旧 §3c)、`docs/BRAND-ASSETS.md` |
|
|
19
|
+
|
|
20
|
+
## 2. 方法与工具(可复核)
|
|
21
|
+
|
|
22
|
+
只使用原始材料:源码、配置、`git`、工具输出。文档只用来**对照**,不作为证据。
|
|
23
|
+
|
|
24
|
+
| 目的 | 方法 / 命令 | 产出 |
|
|
25
|
+
|---|---|---|
|
|
26
|
+
| 基线 | `flutter analyze`、`flutter test`、`node --check`、`node --test test/*.js test/*.mjs` | 改动前后各一份计数,见 §3 |
|
|
27
|
+
| Dart 严格静态分析 | 临时换上 40 余条额外 lint(`avoid_catches_without_on_clauses`、`unawaited_futures`、`discarded_futures`、`avoid_dynamic_calls`、`strict-casts` 等)跑 `flutter analyze` 后恢复原配置 | 590 条提示;绝大多数是风格噪声(163 条宽 `catch`、76 条冗余实参),有信号的是 25 处被丢弃的 Future 与 3 处同步 IO,已处理 |
|
|
28
|
+
| Dart 死代码 | 自写扫描 `dsh-mobile-app/tools/audit/deadcode.py`:去掉注释与字符串后对 `lib/`、`test/` 做标识符计数,只报声明处,**再逐个 grep 人工复核** | 12 个成员 + 11 个常量零引用,已删除 |
|
|
29
|
+
| 资源生命周期 | 逐文件统计 `Timer/listen/AnimationController/*Controller` 的创建与 `cancel/dispose/close` 次数,差异大的文件人工读 | `sheets.dart` 两个控制器从不释放,已修 |
|
|
30
|
+
| 平台配置 | 通读 `AndroidManifest.xml`、`Info.plist`、`Runner.entitlements` | 见 §6 |
|
|
31
|
+
| 缺陷复现 | 先写**失败**的测试 → 看它红 → 修复 → 看它绿;关键修复再做**变异检查**(临时改回旧逻辑,确认测试变红) | §4 |
|
|
32
|
+
| 上帝类拆分 | 自写解析器把 `_ChatScreenState` 切成 205 个成员(文本逐字保留)→ 按功能分组 → 生成 part 文件 → **token 多重集合比对**证明无丢失 | §5 |
|
|
33
|
+
| 真机式验证 | iOS 模拟器 + 演示模式,跑 连接页 → 首页 → 会话 → 设置 → 聊天(流式、工具卡、审批)→ 深色模式 | 截图见 `docs/screenshots/` |
|
|
34
|
+
| Node 侧 | 另见 §4.2:`tsc --checkJs --noUnusedLocals`、引用计数脚本、风险模式 grep、`npm audit`、逐行读认证/限流/LAN 桥/中继 | 详细原文 `docs/AUDIT-2026-11-node.md` |
|
|
35
|
+
|
|
36
|
+
## 3. 数字:改动前 → 改动后
|
|
37
|
+
|
|
38
|
+
| 项 | 前 | 后 |
|
|
39
|
+
|---|---|---|
|
|
40
|
+
| `flutter analyze` | 无问题 | 无问题(并新增 `unawaited_futures`、`cancel_subscriptions` 为强制规则) |
|
|
41
|
+
| `flutter test` | 774 通过 / 18 跳过 | **809 通过 / 18 跳过 / 0 失败**(新增 35 项:本轮缺陷回归 19 + 品牌素材守卫 16) |
|
|
42
|
+
| `node --test` | 426 项 / 418 通过 / 8 跳过 | 490 项 / 482 通过 / 8 跳过 |
|
|
43
|
+
| `lib/index.js` | 7693 行 | 5730 行(拆出 11 个模块,共 2086 行) |
|
|
44
|
+
| `lib/screens/chat_screen.dart` | 8195 行 | 808 行 + `lib/screens/chat/` 16 个 part 文件(每个 66–986 行) |
|
|
45
|
+
| `lib/main.dart` | 1370 行 | 1041 行(连接页抽到 `screens/connection_sheet.dart`) |
|
|
46
|
+
|
|
47
|
+
## 4. 已验证并修复的缺陷
|
|
48
|
+
|
|
49
|
+
### 4.1 Flutter App
|
|
50
|
+
|
|
51
|
+
| # | 位置 | 现象与证据 | 修复 | 回归测试 |
|
|
52
|
+
|---|---|---|---|---|
|
|
53
|
+
| F1 | `Api._normBase` | `http://[fd7a:115c:a1e0::1]:3081` 被改写成 `http://fd7a:115c:a1e0::1:3081`,`Uri.parse` 抛 `Invalid port`(本轮用 `dart run` 复现)。手动输入 IPv6 / Tailscale v6 地址会得到一个坏连接;回环/链路本地过滤也跟着失效。服务端只广播 IPv4,所以扫码路径碰不到 | 主机含 `:` 时补回方括号;`fe80::` 与 `169.254.` 同样排除 | `api_logic_test.dart`(已先红后绿) |
|
|
54
|
+
| F2 | `Api.eventsRaw` SSE 切帧 | 每个帧都重新复制整段剩余文本:20000 帧一次到达耗时 **1736 ms**(2000 帧 33 ms,5000 帧 116 ms,明显二次增长);只认 `\n\n`,代理改成 CRLF 后一个帧都切不出;缓冲无上限 | 抽成纯类 `SseFrameParser`:线性扫描(同样 20000 帧 **8 ms**)、归一 CRLF、8 MiB 上限;`\r\n` 被切在两个 chunk 之间也正确 | `sse_parser_test.dart`(8 项,含任意位置切分) |
|
|
55
|
+
| F3 | `AppLog` | 日志上限 256 KiB,实测会长到 **约 775 KiB**:按 UTF-16 单元而非 UTF-8 字节计(中文差 3 倍),截断后又用 `行数/2*16` 估算 | 按 UTF-8 字节计;截断后取真实文件长度 | `logger_test.dart`(变异检查:改回旧逻辑 → 793608 字节,测试红) |
|
|
56
|
+
| F4 | `_showNewFolder` | `var busy = false` 声明在 `StatefulBuilder` 的 builder 里,每次 `setState` 重建都被重置,源码注释声称的「防连点双建目录」**从未生效**;同时 `TextEditingController` 从不释放。`showActionSheet` 同样泄漏控制器 | 改为 `NewFolderSheet` / `_ActionForm` 两个 StatefulWidget,状态与控制器归 State,路由退出动画后才 dispose | `new_folder_sheet_test.dart`(连点只发一次请求) |
|
|
57
|
+
| F5 | 连接页等 56 处 | 异常直接 `'$e'` 显示:安全存储不可用时用户看到 **`Bad state: 无法使用系统安全存储…`**(本轮在模拟器上看到) | 新增 `errorText()`,去掉 `Bad state: ` / `Exception: ` 前缀;`ApiException` 行为不变 | `error_text_test.dart` |
|
|
58
|
+
| F6 | 25 处被丢弃的 Future | 意图是「发出去就不管」,但与真正漏写 `await` 无法区分 | 显式 `unawaited()`;`unawaited_futures` 进入 `analysis_options.yaml`,以后漏写会被 CI 拦住 | `flutter analyze` |
|
|
59
|
+
| F7 | 首页问候 | 「今天打算设计什么?/ What are you designing today?」是设计工具的遗留文案,与产品(远程操控编码 agent)不符;还硬编码 `Georgia` 字体(Android 没有) | 「要让 Harness 做点什么?」;去掉硬编码字体 | `skin_home_test.dart` |
|
|
60
|
+
| F8 | 设置页 | 每张卡片最后一行多一条分隔线;右侧文案自带 `▸` 又叠一个 `›`(双箭头) | `_SettingsRow` 最后一行不画分隔线;去掉文案里的 `▸` | 模拟器截图对比(`docs/screenshots/` 与旧图) |
|
|
61
|
+
|
|
62
|
+
### 4.2 Node 插件与中继(由子任务执行,已逐项复核计数与关键修复)
|
|
63
|
+
|
|
64
|
+
完整原文:`docs/AUDIT-2026-11-node.md`。摘要:
|
|
65
|
+
|
|
66
|
+
| # | 位置 | 严重度 | 说明 |
|
|
67
|
+
|---|---|---|---|
|
|
68
|
+
| D1 | `relay/node-server.js` upgrade 监听器 | **高** | 未认证请求的目标为 `http://[`、`//[`、`http://:99999999/` 时 `new URL()` 同步抛 `ERR_INVALID_URL`,抛在事件监听器里 = `uncaughtException`,**一条请求即可让公开部署的中继进程退出**。本轮独立复现了这三个目标都会抛。已加 try/catch 并 `socket.destroy()` |
|
|
69
|
+
| D2 | `readJson` | 低 | JSON `null` 请求体让约 40 处 `body.x` 返回 500 |
|
|
70
|
+
| D3 | `index.js` 六个状态文件 | 中 | 不遵守 `DSH_HOME`,两个隔离实例会共用 held 队列与回执文件;**升级后设置了 `DSH_HOME` 的用户会看到一次空的已读/排队/回执/活动状态**,默认路径不变 |
|
|
71
|
+
| D4 | `releaseHeld` | 中 | 图片排队消息在第一次投递未返回时又来一次 idle 事件,会被投递两次 |
|
|
72
|
+
| D5 | `RelayConnector.start()` | 低(潜伏) | `stop()` 后再 `start()`,撤销设备不再踢掉在线会话;生产代码只调一次 `start()`,当前不可达 |
|
|
73
|
+
| C1 | `.github/workflows/ci.yml` | 中 | 语法检查只覆盖 `lib/*.js`;CI 从未安装 `ws`,6 个中继真实套接字测试永远被跳过。已改为检查全部 JS/MJS 并安装 `ws`(**无法在本地运行 GitHub Actions,未验证**) |
|
|
74
|
+
|
|
75
|
+
删除的死代码与 12 个一次性脚本(其断言已并入 `test/`;其中 `verify-issue14-p0` 有 3 条断言早已失效而无人发现)见 Node 原文 §3–§4。
|
|
76
|
+
|
|
77
|
+
## 5. 重构(行为不变)
|
|
78
|
+
|
|
79
|
+
- **`chat_screen.dart`**:`_ChatScreenState` 原为 5200 行、约 60 个字段的单个类。现为:`chat_state_base.dart`(全部字段 + 30 条跨 mixin 调用的方法签名)+ 8 个功能 mixin(`turn_nav`、`history`、`events`、`timeline_view`、`queue`、`composer`、`files`、`actions`)+ 6 个周边控件文件。方法体**逐字搬运**。
|
|
80
|
+
- 证明无损:对拆分前后全部源码做 token 多重集合比对,**丢失的 token 只有 9 个 `static`**(静态成员提到库级),新增的全是 `part`/`mixin`/`@override`/抽象签名/文档注释。
|
|
81
|
+
- 编译器保证每条抽象签名恰好有一份实现;`flutter test` 全量通过;模拟器里实测发消息 → 流式 → 工具卡 → 权限卡 → 允许 → 回复完成。
|
|
82
|
+
- 已知局限:这是「按功能切文件」而非「抽出独立控制器」。mixin 之间仍共享一个状态对象,后续要真正解耦应把 `history/events/queue` 抽成不依赖 `State` 的类。
|
|
83
|
+
- **`main.dart`**:`ConnectionSheet` 抽到 `screens/connection_sheet.dart`。
|
|
84
|
+
- **`lib/index.js`**:纯函数与可独立模块按原文搬到 11 个文件,`index.js` 对外的另外 50 个导出名集合不变(导入后比对)。`handleApi`(约 2800 行)与它共享的闭包状态**没有动**——要动就是重写而不是搬运。
|
|
85
|
+
|
|
86
|
+
## 6. 平台配置审查(只读,未改)
|
|
87
|
+
|
|
88
|
+
| 项 | 观察 | 评估 |
|
|
89
|
+
|---|---|---|
|
|
90
|
+
| Android `usesCleartextTraffic="true"` | 全局放行明文 | LAN 动态 IP 无法按域限定,源码注释已声明为已知权衡;公网场景须走 HTTPS/中继 |
|
|
91
|
+
| Android `MainActivity exported="true"` | 本体无 intent-filter,入口全在 `activity-alias` | 可能不必要;**没有 Android 构建环境,不敢改**,列为后续硬化项 |
|
|
92
|
+
| iOS ATS `NSAllowsLocalNetworking` | 只放行 `.local`、无限定主机名与 IP 字面量 | 经 Tailscale MagicDNS 这类**带域名的 http 地址**会被 ATS 拦截;写入已知限制,未验证 |
|
|
93
|
+
| Keychain 与模拟器 | `--no-codesign` 的模拟器包没有 entitlements,Keychain 报 `-34018` | 环境问题而非 App 缺陷;本轮用 `xcodebuild` 带 ad-hoc 签名构建后正常 |
|
|
94
|
+
| Markdown 链接 | 只放行 `http/https`,有测试 | 良好 |
|
|
95
|
+
|
|
96
|
+
## 7. 品牌与插图替换
|
|
97
|
+
|
|
98
|
+
**问题**:App 图标与首页使用 DeepSeek 鲸鱼标识(`icon-1024.png`、`deepseek-logo.png`、Android 的 `deepseek_logo.png` 以及由它们派生的 8 款图标和全部 iOS/Android 图标位图;代码注释自称「官方 logo(DeepSeek 官网 favicon 转 PNG)」);吉祥物「大肥鱼」(蓝发鲸尾女仆)来自两个第三方仓库、美术出处不清。文档自己把这一项标为「未解决」。
|
|
99
|
+
|
|
100
|
+
**做法(第一轮,已提交)**(委托子任务完成,主审计者独立复核):全部换成仓库内由 Dart `CustomPainter` 绘制的原创素材,不含任何下载图片、AI 生图、字体或图标包。
|
|
101
|
+
|
|
102
|
+
> **第二轮更新(项目方要求,未提交)**:项目方随后提供了两张图片(头像标志、全身插画)并要求使用。因此现在:**默认桌面图标、App 内标志、首页角色用这两张图片**(`tools/brand/supplied_art.py` 生成各尺寸);代码绘制的素材保留用于其余 7 款备选图标和 Android 悬浮宠物(单张静图无法驱动那 16 个动画)。下表第一列描述的是代码绘制的部分。两张图片画的是与旧导入吉祥物同一个角色,**作者与授权无法由仓库核实,已在 `docs/BRAND-ASSETS.md` 留出待项目方填写的表格**。
|
|
103
|
+
|
|
104
|
+
| 素材 | 新内容 | 位置 |
|
|
105
|
+
|---|---|---|
|
|
106
|
+
| 品牌标 | D 形聊天气泡 + 终端提示符 `>_` + 在线绿点;不是鲸鱼,与 DeepSeek 标识无共同轮廓或构图 | `lib/brand/brand_mark.dart` |
|
|
107
|
+
| 8 款桌面图标(id 不变) | 同一枚标的 8 种处理:默认 / 深海荧光 / 贝壳徽章 / 月夜 / 贴纸 / 邮票 / 霓虹 / 单色(兼 Android 13 主题图标层) | `lib/brand/app_icon_art.dart` |
|
|
108
|
+
| 吉祥物「大肥鱼」 | 圆滚滚、竖直站立的非人形小鱼;16 个姿态,四套皮肤 × 明暗 | `lib/brand/mascot.dart`、`lib/widgets/home_pet.dart` |
|
|
109
|
+
| 位图 | iOS AppIcon 全部尺寸(不透明 RGB)、Android 5 个密度 × 8 款 × 前景/背景/单色层、16 个桌宠 WebP 动画(共 2.6 MB,旧的 24 MB) | `tools/brand/build.sh` 一键生成 |
|
|
110
|
+
|
|
111
|
+
**独立复核**
|
|
112
|
+
|
|
113
|
+
- 残留扫描:`grep` 旧文件名 / 旧出处,剩下的只有守卫测试、Kotlin 里指代另一个项目状态机设计的注释,以及一处**界面可见**的「角色素材」署名(`settings_screen.dart`,后来按项目方要求整行删除)。
|
|
114
|
+
- iOS 图标:1024 与 180 像素图均 `hasAlpha: no`;已在 iOS 模拟器的真实主屏上看到新图标。
|
|
115
|
+
- 16 个 WebP:直接解析 RIFF/ANMF 块核对帧数、每帧 84 ms、循环标志、画布 288×229,与 `pet-manifest.json` 全部一致(画布尺寸与旧管线产物相同,Kotlin 的布局假设不变)。
|
|
116
|
+
- 可复现:重跑 `tools/brand/build.sh` 后 171 个生成文件**逐字节一致**。
|
|
117
|
+
- 已知行为变化:为让每个 WebP 不超过约 300 KB,循环段改为 40 帧;一次性动画变短,而 Kotlin 把片长当作脉冲时长——`success` 从 10.2 s 变为 4.0 s,`error` 从 5.0 s 变为 4.7 s。
|
|
118
|
+
- **没有验证**:Android 原生播放(`AnimatedImageDrawable`)、自适应图标在真实启动器里的遮罩、主题图标、Kotlin 构建。本环境没有 Android SDK 与设备。
|
|
119
|
+
|
|
120
|
+
**这不是法律意见**:代码绘制的素材是原创的,且刻意避开了旧标识的轮廓与构图;「名称使用是否合规」只能由项目方/法务判断。
|
|
121
|
+
|
|
122
|
+
## 8. 最终复验
|
|
123
|
+
|
|
124
|
+
全部改动完成后的实测(2026-11-01,本机):
|
|
125
|
+
|
|
126
|
+
| 检查 | 结果 |
|
|
127
|
+
|---|---|
|
|
128
|
+
| `dart format --output=none --set-exit-if-changed lib test` | 通过(CI 同一道门) |
|
|
129
|
+
| `flutter analyze` | No issues found |
|
|
130
|
+
| `flutter test` | **809 通过 / 18 跳过 / 0 失败** |
|
|
131
|
+
| `node --check lib/index.js && node --test test/*.js test/*.mjs` | **490 项 / 482 通过 / 0 失败 / 8 跳过**(6 项是未安装 `ws` 的中继真实套接字测试,2 项是本机没有 Java 的 keystore 测试) |
|
|
132
|
+
| `tools/brand/build.sh` 重跑 | 171 个生成文件与重跑前逐字节一致 |
|
|
133
|
+
| iOS 模拟器(`xcodebuild` ad-hoc 签名,演示模式) | 连接页 → 首页 → 会话 → 通知 → 设置 → 新建会话 → 聊天(发送、流式、工具卡、权限卡、允许、回复完成)→ 深色模式,全部实测通过;新图标出现在真实主屏 |
|
|
134
|
+
| `ios/Runner.xcodeproj/project.pbxproj` | 与 HEAD 逐字节一致(构建工具曾把它从 CRLF 改成 LF,已无损还原;`store-config` 的 set-app-id 测试依赖 CRLF) |
|
|
135
|
+
|
|
136
|
+
两条需要如实说明:
|
|
137
|
+
|
|
138
|
+
- 全量 `flutter test` 在多个后台任务同时跑、机器负载很高时,`sse_follows_base_test`(真实套接字 + 6 秒等待)出现过一次超时失败;单独连跑 4 次全部通过,负载降下来后全量复验也通过。它对负载敏感,不是本轮改动引入的回归,但确是一个脆弱的测试。
|
|
139
|
+
- 本轮没有做真机测试,没有做 Android 构建,没有跑 GitHub Actions。
|
|
140
|
+
|
|
141
|
+
## 8.1 观察到但没有改的行为
|
|
142
|
+
|
|
143
|
+
- **通知权限在首次启动、连接页上就弹出**(还没有任何上下文)。Apple 建议在用户明白用途时再请求。这是行为变化而非视觉问题,只做记录。
|
|
144
|
+
- **模拟器是共享的**:本轮验证期间另一个会话也在用同一台模拟器(Safari 页面、「◀ Floorplan Agent」返回链接),截图时需要留意。
|
|
145
|
+
- 两个设置文案仍含 `选择 ▸` / `上级 ▸` 这种独立箭头(`sheets.dart`),它们没有叠加第二个箭头,所以没动。
|
|
146
|
+
|
|
147
|
+
## 9. 仍未解决 / 未验证
|
|
148
|
+
|
|
149
|
+
- Android 原生代码与资源(悬浮球宠物动画、桌面图标切换、`mipmap`)**没有编译、没有在设备上跑过**。
|
|
150
|
+
- iOS 真机、TestFlight、App Store Connect 隐私问卷与出口合规(见 `docs/STORE-LAUNCH.md`)。
|
|
151
|
+
- 经 GitHub Actions 的 CI(本地无法运行)。
|
|
152
|
+
- 仓库历史里仍保存着旧的 DeepSeek 标识与旧吉祥物文件;只改工作区不会改变历史。是否重写历史由发布者决定。
|
|
153
|
+
- `docs/screenshots/pgy-*.jpg` 是第三方应用(蒲公英)的界面截图,存在引用第三方界面的版权敏感性,本轮**没有删除**,由发布者决定。
|
|
154
|
+
- 根目录未跟踪的 `蓝发鲸尾女仆贴纸少女.png` 是用户提供的旧吉祥物原图,**不要提交**。
|
|
155
|
+
- Node 侧未处理项(会改线上行为或无法复现)见 `docs/AUDIT-2026-11-node.md` §5–§6。
|
|
156
|
+
|
|
157
|
+
## 10. 复核命令
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
# Dart
|
|
161
|
+
cd dsh-mobile-app && flutter analyze && dart format --output=none --set-exit-if-changed lib test && flutter test
|
|
162
|
+
# Node
|
|
163
|
+
node --check lib/index.js && node --test test/*.js test/*.mjs
|
|
164
|
+
# 拆分无损的复现步骤见 dsh-mobile-app/tools/audit/README.md;缺陷复现:
|
|
165
|
+
flutter test test/api_logic_test.dart test/sse_parser_test.dart test/logger_test.dart \
|
|
166
|
+
test/new_folder_sheet_test.dart test/error_text_test.dart
|
|
167
|
+
```
|