dsh-mobile-plugin 0.1.73 → 0.1.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -166
- package/lib/mobile/archive-clean.js +13 -5
- package/lib/panel/index.html +4 -4
- package/lib/session-cleanup.cjs +21 -8
- package/package.json +1 -1
package/lib/session-cleanup.cjs
CHANGED
|
@@ -128,20 +128,30 @@ async function deleteSessionData(sessionIds) {
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
/**
|
|
131
|
-
*
|
|
131
|
+
* 把已经从磁盘删掉的 id 从宿主归档集合里擦掉(删除路径的最后一步,best-effort)。
|
|
132
132
|
*
|
|
133
133
|
* 宿主不会自己修剪这份集合:日志删了它照样留着那些 id,于是「已归档」里是一排点不开的
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
134
|
+
* 死行,而且每清一次就多几条、只增不减。它排在 `deleteSessionData` **之后**:日志没删成
|
|
135
|
+
* 前先擦集合,中途失败就会留下「已取消归档、日志还在」的会话——用户看到的是清理只把会话
|
|
136
|
+
* 移出了归档,还要重启宿主才恢复。先删后擦则日志一没就是真的删掉了,立刻生效;擦失败最多
|
|
137
|
+
* 留一行死行,重试即可。宿主对本来就未归档的 id 是 no-op。
|
|
138
|
+
*
|
|
139
|
+
* 只传**真删掉**的 id:没匹配到日志的还留着日志,擦掉它的名字只会让那一行消失而没有东西被删。
|
|
140
|
+
*
|
|
141
|
+
* 返回擦失败的 id(`failed`),**不抛异常**:日志已经删成功,擦集合坏了不该让整条清理
|
|
142
|
+
* 报错——那等于告诉用户「没删掉」,而事实上已经删掉了。
|
|
137
143
|
*/
|
|
138
144
|
async function forgetArchivedSessions(ctx, sessionIds, rpcId) {
|
|
145
|
+
const failed = []
|
|
139
146
|
const unarchive = ctx && ctx.apiProxy && ctx.apiProxy.workspace ? ctx.apiProxy.workspace.unarchiveSession : undefined
|
|
140
|
-
if (typeof unarchive !== 'function')
|
|
147
|
+
if (typeof unarchive !== 'function') return failed
|
|
141
148
|
for (const sessionId of sessionIds) {
|
|
142
|
-
|
|
143
|
-
|
|
149
|
+
try {
|
|
150
|
+
const { error } = unwrap(await unarchive({ rpcId, method: 'workspace.unarchiveSession', payload: { sessionId } }))
|
|
151
|
+
if (error) failed.push(sessionId)
|
|
152
|
+
} catch { failed.push(sessionId) }
|
|
144
153
|
}
|
|
154
|
+
return failed
|
|
145
155
|
}
|
|
146
156
|
|
|
147
157
|
async function cleanupSessions(ctx, args) {
|
|
@@ -178,8 +188,11 @@ async function cleanupSessions(ctx, args) {
|
|
|
178
188
|
}
|
|
179
189
|
if (args.confirm !== true) throw new Error('永久删除需要 confirm: true')
|
|
180
190
|
const ids = selected.map(item => item.sessionId)
|
|
181
|
-
|
|
191
|
+
// 与移动端那条路由同一口径:**先删日志、再擦归档集合**。反过来会在链路中途失败时
|
|
192
|
+
// 留下「名字已从归档集合消失、日志还在」的会话(看着像只是被移出了归档,得重启宿主
|
|
193
|
+
// 才恢复);先删则日志一没就是真的删掉了,立刻生效。擦集合是收尾,失败不改变结果。
|
|
182
194
|
const deletedIds = await deleteSessionData(ids)
|
|
195
|
+
await forgetArchivedSessions(ctx, deletedIds, 'dsh-mobile-plugin-session-cleanup')
|
|
183
196
|
return { action: args.action, cwd, selected: ids.length, archived: 0, deleted: deletedIds.length, failed: ids.length - deletedIds.length, sessionIds: deletedIds }
|
|
184
197
|
}
|
|
185
198
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-mobile-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.74",
|
|
4
4
|
"description": "Mobile API (/api/mobile/v1) and relay client for the DSH mobile app — desktop profile build (0.2.0-rc.2 compatible, peers resolved by the host)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|