dsh-session-ops 0.2.8 → 0.2.9
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 +2 -3
- package/README.zh.md +3 -3
- package/lib/client.js +20 -46
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,8 +33,7 @@ The plugin row is declared in the bundled `cordis.patch.yml`; its entry id is `s
|
|
|
33
33
|
- `<DSH_HOME>/rewind-snapshots/<session-id>/` (rewind snapshots, if present)
|
|
34
34
|
|
|
35
35
|
All three are removed from disk, and project directories left empty are cleaned up. **There is no
|
|
36
|
-
trash and no undo.** Back up `$DSH_HOME` yourself; the panel provides a dry run and
|
|
37
|
-
confirmation card, but the operator owns the outcome.
|
|
36
|
+
trash and no undo.** Back up `$DSH_HOME` yourself; the panel provides a dry run and a one-click confirmation card, but the operator owns the outcome.
|
|
38
37
|
|
|
39
38
|
The context-menu row resolves through a **single-session probe** (`/session-admin/api/probe`): a
|
|
40
39
|
menu `resolve` gets a 1 s budget (`resolutionTimeoutMs`, and a timed-out provider is dropped), while
|
|
@@ -42,7 +41,7 @@ a table-wide dry run measures every session directory (≈3.6 s for 391 sessions
|
|
|
42
41
|
used to appear only sometimes. The probe skips byte measurement and shares the exact guard chain
|
|
43
42
|
with `delete`; it only decides whether the row is enabled, and `delete` re-checks every guard. The
|
|
44
43
|
confirmation card is drawn in the page (never `window.confirm` / `window.prompt`: Electron throws
|
|
45
|
-
`prompt() is not supported.`)
|
|
44
|
+
`prompt() is not supported.`) and deliberately asks for a single click — no typed confirmation word.
|
|
46
45
|
|
|
47
46
|
Safe defaults (configurable): `allowWorkspaceSessions=false`, `allowLiveSessions=false`,
|
|
48
47
|
`refuseRunning=true` — workspace sessions, live sessions and mid-turn moves are refused by default.
|
package/README.zh.md
CHANGED
|
@@ -28,9 +28,9 @@ dsh plugin --profile <profile> add dsh-session-ops
|
|
|
28
28
|
- `<DSH_HOME>/storages/session_projcache/sessions/<session-id>.json`:投影缓存
|
|
29
29
|
- `<DSH_HOME>/rewind-snapshots/<session-id>/`:回退快照(若有)
|
|
30
30
|
|
|
31
|
-
删除后顺手清理因此变空的项目目录。没有回收站,删了无法恢复;删除前请自行备份 `$DSH_HOME
|
|
31
|
+
删除后顺手清理因此变空的项目目录。没有回收站,删了无法恢复;删除前请自行备份 `$DSH_HOME`。面板提供预演与确认卡片(弹出来点一次「删除」即可),但最终责任在操作者。
|
|
32
32
|
|
|
33
|
-
右键菜单的「删除会话…」用**单条预演**(`/session-admin/api/probe`)决定能不能点:菜单的 `resolve` 只有 1 s 预算(`resolutionTimeoutMs`,超时整项被丢弃),而整表 dryRun 要把每个会话目录的体积都走一遍(本机 391 条约 3.6 s),结果就是这一项在菜单里时有时无。`probe` 只做无体积统计的扫描 + 与 `delete` **同一份**守卫判定,毫秒级返回 `{removable, reason}`;它只管菜单显示,真删时 `delete` 会重新过一遍守卫。确认卡片是页面里自己画的(不用 `window.confirm` / `window.prompt`——Electron 里 `window.prompt` 直接抛 `prompt() is not supported
|
|
33
|
+
右键菜单的「删除会话…」用**单条预演**(`/session-admin/api/probe`)决定能不能点:菜单的 `resolve` 只有 1 s 预算(`resolutionTimeoutMs`,超时整项被丢弃),而整表 dryRun 要把每个会话目录的体积都走一遍(本机 391 条约 3.6 s),结果就是这一项在菜单里时有时无。`probe` 只做无体积统计的扫描 + 与 `delete` **同一份**守卫判定,毫秒级返回 `{removable, reason}`;它只管菜单显示,真删时 `delete` 会重新过一遍守卫。确认卡片是页面里自己画的(不用 `window.confirm` / `window.prompt`——Electron 里 `window.prompt` 直接抛 `prompt() is not supported.`):卡片刻意只用一次点击,不要求输入确认词。
|
|
34
34
|
|
|
35
35
|
默认安全边界(可在配置里改):`allowWorkspaceSessions=false`、`allowLiveSessions=false`、`refuseRunning=true`。工作区会话、正在跑的会话、运行中的搬迁默认都被拒绝。
|
|
36
36
|
|
|
@@ -58,7 +58,7 @@ DSH 0.2.2-rc.3 起,会话标题栏的「会话面板」里会出现本插件
|
|
|
58
58
|
| `root` | `''` | 会话根目录;空则取 `sessionPersistence.root`(jsonl 后端为 `$DSH_HOME/sessions`) |
|
|
59
59
|
| `adminAllowHosts` | `[]` | 删除半边的 LAN 信任列表(按 `Host` 头解析 `host` 或 `host:port`) |
|
|
60
60
|
| `moveAllowHosts` | `[]` | 搬迁半边的 LAN 信任列表(按 `Host` 头完整值精确匹配) |
|
|
61
|
-
| `headerDeleteButton` | `true` | 会话标题栏垃圾桶图标(图标 +
|
|
61
|
+
| `headerDeleteButton` | `true` | 会话标题栏垃圾桶图标(图标 + 一次点击的确认卡片) |
|
|
62
62
|
| `allowWorkspaceSessions` | `false` | 允许删除已归属工作区的会话 |
|
|
63
63
|
| `allowLiveSessions` | `false` | 允许删除宿主里驻留的会话 |
|
|
64
64
|
| `maxBatch` | `200` | 单次批量删除上限 |
|
package/lib/client.js
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* 与 `dsh-session-move:panel`(+`…:panel-via-better-sidebar`),标题分别是
|
|
23
23
|
* 「会话管理」「会话归位」,角标语义不变(删除半边:未分组条数;搬迁半边:无);
|
|
24
24
|
* - 会话标题栏垃圾桶的 id `dsh-session-admin:delete-current`(仍然是**图标**,
|
|
25
|
-
* 开关由 Host 的 `headerDeleteButton`
|
|
25
|
+
* 开关由 Host 的 `headerDeleteButton` 决定,默认开启,删除要过一次确认卡片);
|
|
26
26
|
* - 数据面仍然只打各自的前缀:`/session-admin/api` 与 `/session-move/api`。
|
|
27
27
|
*
|
|
28
28
|
* ## 统一右键菜单(DSH 0.2.2-rc.1 起)
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
* - 「移动会话到工作区…」(搬迁半边,order 500):菜单里只判断能不能搬并写出理由,
|
|
34
34
|
* 点下去时重新读一次 Host 状态,然后打开既有右栏「会话归位」面板并选中这条会话;
|
|
35
35
|
* - 「删除会话…」(删除半边,order 620,`afterContent` 与原生「归档」同区):与标题栏
|
|
36
|
-
* 垃圾桶**共用** `deleteSessionFlow`(预演 →
|
|
36
|
+
* 垃圾桶**共用** `deleteSessionFlow`(预演 → 确认卡片 → 删除),`run` 里会再预演
|
|
37
37
|
* 一次,所以菜单打开到点下去之间状态变了也不会绕过守卫。
|
|
38
38
|
*
|
|
39
39
|
* 两项的图标注册在 `contextMenu.icon` 的 keyed slot 上;没有 `contextMenus` 服务
|
|
@@ -155,8 +155,9 @@
|
|
|
155
155
|
* `删除失败:prompt() is not supported.`——功能看起来像坏了,其实一次都没删过。
|
|
156
156
|
* 卡片挂在 `document.body` 上,不依赖宿主对话框,桌面端与浏览器行为一致。
|
|
157
157
|
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
158
|
+
* 一步:说明删什么,点「删除」即可。「删除」是危险色按钮且排在最后,误点仍要
|
|
159
|
+
* 多走一步;Esc、取消、点遮罩都按取消处理。
|
|
160
|
+
*
|
|
160
161
|
* @param summary - 这次删除的对象描述(条数、体积或会话 id)。
|
|
161
162
|
* @returns 用户是否确认删除。
|
|
162
163
|
*/
|
|
@@ -178,7 +179,7 @@
|
|
|
178
179
|
card.setAttribute('role', 'alertdialog');
|
|
179
180
|
card.setAttribute('aria-modal', 'true');
|
|
180
181
|
card.style.width = '100%';
|
|
181
|
-
card.style.maxWidth = '
|
|
182
|
+
card.style.maxWidth = '400px';
|
|
182
183
|
card.style.boxSizing = 'border-box';
|
|
183
184
|
card.style.display = 'flex';
|
|
184
185
|
card.style.flexDirection = 'column';
|
|
@@ -198,16 +199,6 @@
|
|
|
198
199
|
note.style.lineHeight = '1.5';
|
|
199
200
|
note.style.color = 'var(--dsw-alias-label-secondary, rgba(128, 128, 128, 0.95))';
|
|
200
201
|
note.textContent = '会话日志、投影缓存与回退快照一并移除,无法撤销。';
|
|
201
|
-
const input = document.createElement('input');
|
|
202
|
-
input.type = 'text';
|
|
203
|
-
input.autocomplete = 'off';
|
|
204
|
-
input.placeholder = '输入「删除」以确认';
|
|
205
|
-
input.style.padding = '6px 9px';
|
|
206
|
-
input.style.fontSize = '12.5px';
|
|
207
|
-
input.style.borderRadius = '8px';
|
|
208
|
-
input.style.border = '1px solid var(--dsw-alias-border-l2, var(--dsh-border, #d0d5dd))';
|
|
209
|
-
input.style.background = 'transparent';
|
|
210
|
-
input.style.color = 'inherit';
|
|
211
202
|
const bar = document.createElement('div');
|
|
212
203
|
bar.style.display = 'flex';
|
|
213
204
|
bar.style.gap = '8px';
|
|
@@ -221,25 +212,17 @@
|
|
|
221
212
|
accept.type = 'button';
|
|
222
213
|
accept.textContent = '删除';
|
|
223
214
|
accept.style.cssText =
|
|
224
|
-
'padding:5px 12px;font-size:12.5px;border-radius:8px;border:1px solid transparent;background:var(--dsw-alias-state-error-primary, #d92d20);color:#fff';
|
|
225
|
-
/** 输入框内容 → 确认按钮可用性(唯一判据:整串等于「删除」)。 */
|
|
226
|
-
function syncAccept() {
|
|
227
|
-
const ready = input.value.trim() === '删除';
|
|
228
|
-
accept.disabled = !ready;
|
|
229
|
-
accept.style.opacity = ready ? '1' : '0.45';
|
|
230
|
-
accept.style.cursor = ready ? 'pointer' : 'default';
|
|
231
|
-
}
|
|
215
|
+
'padding:5px 12px;font-size:12.5px;border-radius:8px;border:1px solid transparent;background:var(--dsw-alias-state-error-primary, #d92d20);color:#fff;cursor:pointer';
|
|
232
216
|
let settled = false;
|
|
233
217
|
function finish(confirmed) {
|
|
234
218
|
if (settled)
|
|
235
219
|
return;
|
|
236
220
|
settled = true;
|
|
237
221
|
confirmDeletionOpen = false;
|
|
238
|
-
input.removeEventListener('input', syncAccept);
|
|
239
|
-
input.removeEventListener('keydown', onKey);
|
|
240
222
|
dismiss.removeEventListener('click', onDismiss);
|
|
241
223
|
accept.removeEventListener('click', onAccept);
|
|
242
224
|
overlay.removeEventListener('mousedown', onBackdrop);
|
|
225
|
+
document.removeEventListener('keydown', onKey, true);
|
|
243
226
|
if (overlay.parentNode !== null)
|
|
244
227
|
overlay.parentNode.removeChild(overlay);
|
|
245
228
|
resolve(confirmed);
|
|
@@ -248,42 +231,33 @@
|
|
|
248
231
|
finish(false);
|
|
249
232
|
}
|
|
250
233
|
function onAccept() {
|
|
251
|
-
|
|
252
|
-
finish(true);
|
|
234
|
+
finish(true);
|
|
253
235
|
}
|
|
254
236
|
function onBackdrop(event) {
|
|
255
237
|
if (event.target === overlay)
|
|
256
238
|
finish(false);
|
|
257
239
|
}
|
|
258
240
|
function onKey(event) {
|
|
259
|
-
if (event.key
|
|
260
|
-
if (typeof event.preventDefault === 'function')
|
|
261
|
-
event.preventDefault();
|
|
262
|
-
finish(false);
|
|
241
|
+
if (event.key !== 'Escape')
|
|
263
242
|
return;
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
event.preventDefault();
|
|
268
|
-
finish(true);
|
|
269
|
-
}
|
|
243
|
+
if (typeof event.preventDefault === 'function')
|
|
244
|
+
event.preventDefault();
|
|
245
|
+
finish(false);
|
|
270
246
|
}
|
|
271
|
-
input.addEventListener('input', syncAccept);
|
|
272
|
-
input.addEventListener('keydown', onKey);
|
|
273
247
|
dismiss.addEventListener('click', onDismiss);
|
|
274
248
|
accept.addEventListener('click', onAccept);
|
|
275
249
|
overlay.addEventListener('mousedown', onBackdrop);
|
|
250
|
+
// Esc 兜底:捕获阶段监听,输入框有焦点时也收得到。
|
|
251
|
+
document.addEventListener('keydown', onKey, true);
|
|
276
252
|
card.appendChild(what);
|
|
277
253
|
card.appendChild(note);
|
|
278
|
-
card.appendChild(input);
|
|
279
254
|
bar.appendChild(dismiss);
|
|
280
255
|
bar.appendChild(accept);
|
|
281
256
|
card.appendChild(bar);
|
|
282
257
|
overlay.appendChild(card);
|
|
283
|
-
syncAccept();
|
|
284
258
|
document.body.appendChild(overlay);
|
|
285
|
-
if (typeof
|
|
286
|
-
|
|
259
|
+
if (typeof accept.focus === 'function')
|
|
260
|
+
accept.focus();
|
|
287
261
|
});
|
|
288
262
|
}
|
|
289
263
|
/** 时间戳 → `MM-DD HH:mm`。 */
|
|
@@ -816,7 +790,7 @@
|
|
|
816
790
|
? h('div', { style: { marginTop: 6 } }, h('div', { style: S.muted }, `未处理 ${refusalRows.length} 条:`), refusalRows.slice(0, 12).map((row) => h('div', { key: row.id, style: S.muted }, `${row.id} — ${REASONS[row.reason] ?? row.reason}`)), refusalRows.length > 12 ? h('div', { style: S.muted }, `…以及另外 ${refusalRows.length - 12} 条`) : null)
|
|
817
791
|
: null);
|
|
818
792
|
// 待删除队列:条目、状态、撤销、立即重试。
|
|
819
|
-
return h('div', { style: fill ? { ...S.root, ...S_FILL.root } : S.root }, h('div', { style: S.muted }, 'DSH
|
|
793
|
+
return h('div', { style: fill ? { ...S.root, ...S_FILL.root } : S.root }, h('div', { style: S.muted }, 'DSH 只能「归档」(隐藏)会话;这里做的是把会话的持久化数据真正从磁盘移除。删除会弹一张确认卡片,确认后不可恢复。'), head, pathBar, toolbar, failure !== undefined ? h('div', { style: S.error }, `失败:${failure}`) : null, list, resultBox);
|
|
820
794
|
};
|
|
821
795
|
}
|
|
822
796
|
/** 右侧页签的标题条。 */
|
|
@@ -958,7 +932,7 @@
|
|
|
958
932
|
return { sessionId, removable: report?.removed > 0, reason: row?.reason };
|
|
959
933
|
}
|
|
960
934
|
/**
|
|
961
|
-
* 删除一个会话的整条流程:预演 →
|
|
935
|
+
* 删除一个会话的整条流程:预演 → 确认卡片 → 删除。
|
|
962
936
|
*
|
|
963
937
|
* 标题栏垃圾桶与右键菜单共用这一段:两处删的是同一个东西,只是入口不同,守卫与
|
|
964
938
|
* 确认必须逐字一致,否则「从菜单删」就等于绕开「从图标删」的那些检查。
|
|
@@ -1145,7 +1119,7 @@
|
|
|
1145
1119
|
key: 'headerDeleteButton',
|
|
1146
1120
|
kind: 'boolean',
|
|
1147
1121
|
label: '标题栏删除图标',
|
|
1148
|
-
hint: '
|
|
1122
|
+
hint: '在会话标题栏显示垃圾桶图标(默认开启)。它是图标而不是按钮,且删除要过一次确认卡片。改完刷新页面生效。',
|
|
1149
1123
|
},
|
|
1150
1124
|
{
|
|
1151
1125
|
key: 'allowLiveSessions',
|