@kangyishuai/dsh-session-delete 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -14
- package/README.zh-CN.md +13 -14
- package/lib/capability.js +10 -4
- package/lib/client.js +157 -2
- package/lib/operations.js +46 -0
- package/lib/service.js +26 -0
- package/locale/en.json +7 -1
- package/locale/zh.json +7 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
Unofficial plugin for [DeepSeek Harness (DSH)](https://github.com/deepseek-ai). Not affiliated with DeepSeek.
|
|
8
8
|
|
|
9
|
-
> **Status: v0.
|
|
9
|
+
> **Status: v0.4.1, early.** Verified on DSH 0.2.1-rc.5 with `pnpm smoke:session-delete` (24 end-to-end assertions) plus a manual pass in the desktop GUI. Treat it as young software and keep backups of anything you cannot lose.
|
|
10
10
|
|
|
11
11
|
## What it does
|
|
12
12
|
|
|
@@ -38,6 +38,8 @@ Restart the DSH desktop app afterwards. A fresh install adds a host half, so rel
|
|
|
38
38
|
|
|
39
39
|
## Usage
|
|
40
40
|
|
|
41
|
+
**Batch (in trash)**: the trash tab supports select-all / clear / batch restore / batch permanent delete; each entry is handled independently and failures are reported inline.
|
|
42
|
+
|
|
41
43
|
**Agent tool**: models can call `session_delete`, but only in two steps — `action=plan` returns the impact summary plus a single-use token (2 minutes), and `action=delete` needs that token. It refuses to delete the calling session, and a changed session invalidates the token. Deleting from the UI never requires the tool.
|
|
42
44
|
|
|
43
45
|
**Keyboard**: Tab between controls, Enter/Space to activate, Esc to close a dialog. In the trash panel, ↑/↓/Home/End move focus between rows. `⌘/Ctrl + Alt + T` opens the trash. There is no one-key delete shortcut — deletion always goes through the menu and a confirmation dialog.
|
|
@@ -89,15 +91,17 @@ Archive is a bookmark, not a deletion: DSH adds the session id to the workspace'
|
|
|
89
91
|
|
|
90
92
|
v0.1 declares no `engines.dsh` range. Instead there are three layers of defense:
|
|
91
93
|
|
|
92
|
-
| Layer
|
|
93
|
-
|
|
|
94
|
-
| L1 version gate
|
|
95
|
-
| L2 startup self-check
|
|
96
|
-
|
|
94
|
+
| Layer | When it runs | What it does | What you see |
|
|
95
|
+
| --------------------- | -------------------- | ------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
96
|
+
| L1 version gate | install / activation | `engines.dsh` version range. **Not declared in v0.1**, so this layer is currently inactive. | nothing |
|
|
97
|
+
| L2 startup self-check | plugin activation | Probes every host capability it depends on and grades them api / internal / unknown. | **Degraded mode**: a host without `workspaceRegistry` (for example the headless composition) still allows deletion — the archive gate and workspace bookkeeping steps are skipped and reported in the receipt. Only a missing persistence seam puts the plugin in read-only mode. |
|
|
98
|
+
|
|
99
|
+
**Read-only mode**: plan, audit and trash listing keep working; delete, restore and purge are disabled. |
|
|
100
|
+
| L3 per-operation refusal | every operation | Each operation re-checks its own prerequisites; unknown always refuses. | A structured error code plus a human-readable reason, and no half-deleted state. |
|
|
97
101
|
|
|
98
102
|
| Plugin | Verified on DSH | Notes |
|
|
99
103
|
| ------ | ------------------------ | ------------------------------------------------------------------------------------------- |
|
|
100
|
-
| 0.
|
|
104
|
+
| 0.4.1 | **0.2.1-rc.5** (desktop) | `pnpm smoke:session-delete`: 24 assertions green; manual GUI pass on the same host version. |
|
|
101
105
|
|
|
102
106
|
After a DSH upgrade: restart, then open the plugin status (settings → plugins). If it reports read-only mode, the host API changed — upgrade the plugin or report the version pair; don't force it.
|
|
103
107
|
|
|
@@ -112,13 +116,6 @@ After a DSH upgrade: restart, then open the plugin status (settings → plugins)
|
|
|
112
116
|
| Purge left something behind | Residue that the post-delete receipt lists | Read the receipt and the audit log, clean the listed path by hand, and open an issue with the receipt |
|
|
113
117
|
| The trash panel is empty after a delete | The plugin resolved a different data root than your DSH (`DSH_HOME` / config) | Look at `~/.dsh/session-trash/` on disk and check the plugin's `dataRoot` config |
|
|
114
118
|
|
|
115
|
-
## Roadmap (later releases)
|
|
116
|
-
|
|
117
|
-
The following are planned and not implemented yet:
|
|
118
|
-
|
|
119
|
-
- batch deletion (multi-select);
|
|
120
|
-
- an undo toast after a delete.
|
|
121
|
-
|
|
122
119
|
## License
|
|
123
120
|
|
|
124
121
|
MIT — see [LICENSE](./LICENSE). The repository's [NOTICE](https://github.com/kangyishuai/dsh-plugins/blob/main/NOTICE) credits the community projects whose _design_ informed this plugin; no code was copied from them.
|
package/README.zh-CN.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
非官方 [DeepSeek Harness (DSH)](https://github.com/deepseek-ai) 插件,与 DeepSeek 无关。
|
|
8
8
|
|
|
9
|
-
> **状态:v0.
|
|
9
|
+
> **状态:v0.4.1,早期可用。** 已在 DSH 0.2.1-rc.5 上用 `pnpm smoke:session-delete`(24 项端到端断言)加一轮桌面版人工验收。仍是年轻软件,重要数据请自行备份。
|
|
10
10
|
|
|
11
11
|
## 做什么
|
|
12
12
|
|
|
@@ -38,6 +38,8 @@ dsh plugin --profile desktop add /tmp/kangyishuai-dsh-session-delete-*.tgz
|
|
|
38
38
|
|
|
39
39
|
## 使用
|
|
40
40
|
|
|
41
|
+
**回收站内批量**:回收站页签支持全选/清空/批量恢复/批量彻底删除,逐条执行,失败的条目会在面板里说明。
|
|
42
|
+
|
|
41
43
|
**Agent 工具**:模型可以调用 `session_delete`,但必须两段式——`action=plan` 返回影响面摘要和一次性 token(2 分钟有效),`action=delete` 必须带这个 token。它拒绝删除调用者自己的会话,会话在此期间变化会让 token 失效。通过 UI 删除不需要这个工具。
|
|
42
44
|
|
|
43
45
|
**键盘**:Tab 在各按钮间移动,Enter/Space 触发,Esc 关闭对话框;回收站面板里可用 ↑/↓/Home/End 在条目间移动焦点;`⌘/Ctrl + Alt + T` 直接打开回收站。删除始终需要菜单 + 确认框,没有一键删除的快捷键。
|
|
@@ -89,15 +91,19 @@ dsh plugin --profile desktop add /tmp/kangyishuai-dsh-session-delete-*.tgz
|
|
|
89
91
|
|
|
90
92
|
v0.1 没有声明 `engines.dsh` 版本范围,改用三层防线:
|
|
91
93
|
|
|
92
|
-
| 层
|
|
93
|
-
|
|
|
94
|
-
| L1 版本闸门
|
|
95
|
-
| L2 启动自检
|
|
96
|
-
|
|
94
|
+
| 层 | 触发时机 | 做什么 | 你会看到什么 |
|
|
95
|
+
| ----------- | ----------- | ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
96
|
+
| L1 版本闸门 | 安装 / 激活 | `engines.dsh` 版本范围。**v0.1 尚未声明**,这一层目前不生效。 | 无 |
|
|
97
|
+
| L2 启动自检 | 插件激活时 | 探测所有依赖的宿主能力,分成 api / internal / unknown 三档。 | 进入**降级模式**:宿主没有 `workspaceRegistry`(例如 headless 组合)时仍然允许删除——归档闸门与工作区记账步骤会被跳过并写进回执。只有持久化本体缺失时才进入只读模式。 |
|
|
98
|
+
|
|
99
|
+
**只读模式**:plan、审计、回收站列表还能用;删除、恢复、彻底删除被禁用。 |
|
|
100
|
+
| L3 执行期拒绝 | 每次操作 | 每个操作自己再校验前置能力,unknown 一律拒绝。 | 结构化错误码 + 人类可读原因,磁盘上不会出现删了一半的状态。 |
|
|
97
101
|
|
|
98
102
|
| 插件版本 | 已验证的 DSH 版本 | 说明 |
|
|
99
103
|
| -------- | ------------------------ | -------------------------------------------------------------------------------- |
|
|
100
|
-
| 0.
|
|
104
|
+
| 0.4.1 | **0.2.1-rc.5**(桌面版) | `pnpm smoke:session-delete` 24 项断言全绿,并在同一版本桌面版做过人工 GUI 验收。 |
|
|
105
|
+
|
|
106
|
+
目前只在 **macOS** 上验证过。Windows 相关路径(`session.lock` 的 EBUSY/EPERM 重试、宿主在那儿用的命名信号量)代码里有,但**还没实测**。
|
|
101
107
|
|
|
102
108
|
DSH 升级之后:重启,然后看插件的状态条(设置 → 插件)。如果显示只读模式,说明宿主 API 变了——升级插件,或者把两个版本号一起报上来,别硬用。
|
|
103
109
|
|
|
@@ -112,13 +118,6 @@ DSH 升级之后:重启,然后看插件的状态条(设置 → 插件)
|
|
|
112
118
|
| 彻底删除后还残留东西 | 删除回执里列出的残留 | 对回执和审计日志,按回执里的路径手动清理,并把回执附在 issue 里 |
|
|
113
119
|
| 删完之后回收站是空的 | 插件解析到的数据根目录和你的 DSH 不是同一个(`DSH_HOME` / 配置) | 去磁盘上看 `~/.dsh/session-trash/`,再核对插件的 `dataRoot` 配置 |
|
|
114
120
|
|
|
115
|
-
## 计划中(后续版本)
|
|
116
|
-
|
|
117
|
-
下面这些是计划,尚未实现:
|
|
118
|
-
|
|
119
|
-
- 批量删除(多选);
|
|
120
|
-
- 删除后的撤销 toast。
|
|
121
|
-
|
|
122
121
|
## License
|
|
123
122
|
|
|
124
123
|
MIT,见 [LICENSE](./LICENSE)。本插件借鉴了若干社区项目的**设计**(不是代码),来源记在仓库的 [NOTICE](https://github.com/kangyishuai/dsh-plugins/blob/main/NOTICE)。
|
package/lib/capability.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// 宿主能力探测。整个插件对宿主内部契约的依赖只在这里出现一次,
|
|
3
3
|
// 这样 DSH 升级后需要改的地方永远只有一个文件(见 docs/adr/0005)。
|
|
4
4
|
|
|
5
|
-
/** @typedef {"api" | "internal" | "unknown"} CapabilityTier */
|
|
5
|
+
/** @typedef {"api" | "internal" | "minimal" | "unknown"} CapabilityTier */
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @typedef {object} Capabilities
|
|
@@ -33,10 +33,12 @@ function callable(target, key) {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
*
|
|
36
|
+
* 探测本插件依赖的全部宿主能力,并按四档给出结论:
|
|
37
37
|
* - api:官方文档里有的一等公民能力齐全;
|
|
38
38
|
* - internal:核心可用,但有依赖社区契约的部件(会降级执行并告警);
|
|
39
|
-
* -
|
|
39
|
+
* - minimal:缺少 workspaceRegistry(如 headless 组合),删除仍可做,
|
|
40
|
+
* 归档闸门/工作区记账等步骤跳过并在回执里标记;
|
|
41
|
+
* - unknown:持久化本体缺失,破坏性操作必须拒绝。
|
|
40
42
|
*
|
|
41
43
|
* @param {any} ctx host 上下文。
|
|
42
44
|
* @returns {Capabilities}
|
|
@@ -75,7 +77,10 @@ export function probeCapabilities(ctx) {
|
|
|
75
77
|
|
|
76
78
|
/** @type {CapabilityTier} */
|
|
77
79
|
let tier = "api";
|
|
78
|
-
|
|
80
|
+
// 删除本身只需要持久化读取 + 文件系统;工作区/归档只是闸门与记账,
|
|
81
|
+
// 缺失时降级为 minimal(跳过对应步骤并报告),不应整体禁用。
|
|
82
|
+
const essential = ["persistence.stat"];
|
|
83
|
+
const workspaceGate = ["workspace.archive", "workspace.unarchive"];
|
|
79
84
|
const convenient = [
|
|
80
85
|
"persistence.list",
|
|
81
86
|
"persistence.locate",
|
|
@@ -86,6 +91,7 @@ export function probeCapabilities(ctx) {
|
|
|
86
91
|
"event.session-activity",
|
|
87
92
|
];
|
|
88
93
|
if (essential.some((k) => !table[k])) tier = "unknown";
|
|
94
|
+
else if (workspaceGate.some((k) => !table[k])) tier = "minimal";
|
|
89
95
|
else if (convenient.some((k) => !table[k])) tier = "internal";
|
|
90
96
|
|
|
91
97
|
return {
|
package/lib/client.js
CHANGED
|
@@ -70,6 +70,12 @@ window.__ModuleLoader__.load({
|
|
|
70
70
|
"panel.tabAudit": "审计",
|
|
71
71
|
"panel.tabHealth": "体检",
|
|
72
72
|
"panel.tabReceipts": "回执",
|
|
73
|
+
"trash.selectAll": "全选",
|
|
74
|
+
"trash.clear": "清空",
|
|
75
|
+
"trash.restoreMany": "批量恢复({n})",
|
|
76
|
+
"trash.purgeMany": "批量彻底删除({n})",
|
|
77
|
+
"trash.purgeManyConfirm": "确认彻底删除 {n} 个?不可恢复",
|
|
78
|
+
"batch.done": "完成:{ok}/{total} 成功",
|
|
73
79
|
"receipts.empty": "还没有操作回执。",
|
|
74
80
|
"receipts.restored": "已移回原位置",
|
|
75
81
|
"health.loading": "正在检查…",
|
|
@@ -124,6 +130,12 @@ window.__ModuleLoader__.load({
|
|
|
124
130
|
"panel.tabAudit": "Audit",
|
|
125
131
|
"panel.tabHealth": "Health",
|
|
126
132
|
"panel.tabReceipts": "Receipts",
|
|
133
|
+
"trash.selectAll": "Select all",
|
|
134
|
+
"trash.clear": "Clear",
|
|
135
|
+
"trash.restoreMany": "Restore {n}",
|
|
136
|
+
"trash.purgeMany": "Delete {n} permanently",
|
|
137
|
+
"trash.purgeManyConfirm": "Permanently delete {n}? This cannot be undone",
|
|
138
|
+
"batch.done": "Done: {ok}/{total} succeeded",
|
|
127
139
|
"receipts.empty": "No operation receipts yet.",
|
|
128
140
|
"receipts.restored": "restored",
|
|
129
141
|
"health.loading": "Checking…",
|
|
@@ -243,7 +255,11 @@ window.__ModuleLoader__.load({
|
|
|
243
255
|
description: props.description,
|
|
244
256
|
footer: props.footer,
|
|
245
257
|
},
|
|
246
|
-
h(
|
|
258
|
+
h(
|
|
259
|
+
Reveal,
|
|
260
|
+
{ style: { maxHeight: "60vh", overflowY: "auto", paddingRight: "4px" } },
|
|
261
|
+
props.children,
|
|
262
|
+
),
|
|
247
263
|
);
|
|
248
264
|
}
|
|
249
265
|
return h(
|
|
@@ -643,6 +659,15 @@ window.__ModuleLoader__.load({
|
|
|
643
659
|
var purgeState = React.useState(null);
|
|
644
660
|
var confirmPurge = purgeState[0];
|
|
645
661
|
var setConfirmPurge = purgeState[1];
|
|
662
|
+
var selectedTrashState = React.useState({});
|
|
663
|
+
var selectedTrash = selectedTrashState[0];
|
|
664
|
+
var setSelectedTrash = selectedTrashState[1];
|
|
665
|
+
var trashBusyState = React.useState(false);
|
|
666
|
+
var trashBusy = trashBusyState[0];
|
|
667
|
+
var setTrashBusy = trashBusyState[1];
|
|
668
|
+
var trashMsgState = React.useState("");
|
|
669
|
+
var trashMsg = trashMsgState[0];
|
|
670
|
+
var setTrashMsg = trashMsgState[1];
|
|
646
671
|
var scanState = React.useState(null);
|
|
647
672
|
var scan = scanState[0];
|
|
648
673
|
var setScan = scanState[1];
|
|
@@ -783,6 +808,49 @@ window.__ModuleLoader__.load({
|
|
|
783
808
|
});
|
|
784
809
|
};
|
|
785
810
|
|
|
811
|
+
var selectedEntryIds = Object.keys(selectedTrash).filter(
|
|
812
|
+
(/** @type {string} */ entryId) => /** @type {any} */ (selectedTrash)[entryId],
|
|
813
|
+
);
|
|
814
|
+
var doBatchRestore = () => {
|
|
815
|
+
if (selectedEntryIds.length === 0) return;
|
|
816
|
+
setTrashBusy(true);
|
|
817
|
+
setTrashMsg("");
|
|
818
|
+
props
|
|
819
|
+
.call("restoreMany", { entryIds: selectedEntryIds })
|
|
820
|
+
.then((/** @type {any} */ result) => {
|
|
821
|
+
setTrashBusy(false);
|
|
822
|
+
setTrashMsg(props.t("batch.done", { ok: result.succeeded, total: result.total }));
|
|
823
|
+
setSelectedTrash({});
|
|
824
|
+
refresh();
|
|
825
|
+
props.bump?.();
|
|
826
|
+
for (const item of result.results) if (item.ok) props.onRestored?.(item.sessionId);
|
|
827
|
+
})
|
|
828
|
+
.catch((/** @type {any} */ reason) => {
|
|
829
|
+
setTrashBusy(false);
|
|
830
|
+
setTrashMsg(errorText(reason));
|
|
831
|
+
});
|
|
832
|
+
};
|
|
833
|
+
var doBatchPurge = () => {
|
|
834
|
+
if (selectedEntryIds.length === 0) return;
|
|
835
|
+
setTrashBusy(true);
|
|
836
|
+
setTrashMsg("");
|
|
837
|
+
props
|
|
838
|
+
.call("purgeMany", { entryIds: selectedEntryIds })
|
|
839
|
+
.then((/** @type {any} */ result) => {
|
|
840
|
+
setTrashBusy(false);
|
|
841
|
+
setConfirmPurge(null);
|
|
842
|
+
setTrashMsg(props.t("batch.done", { ok: result.succeeded, total: result.total }));
|
|
843
|
+
setSelectedTrash({});
|
|
844
|
+
refresh();
|
|
845
|
+
props.bump?.();
|
|
846
|
+
for (const item of result.results) if (item.ok) props.onPurged?.(undefined);
|
|
847
|
+
})
|
|
848
|
+
.catch((/** @type {any} */ reason) => {
|
|
849
|
+
setTrashBusy(false);
|
|
850
|
+
setTrashMsg(errorText(reason));
|
|
851
|
+
});
|
|
852
|
+
};
|
|
853
|
+
|
|
786
854
|
var entries = (data && data.entries) || [];
|
|
787
855
|
var readOnly = !!(health && health.readOnly);
|
|
788
856
|
var rowStyle = { borderTop: "1px solid " + T.border, padding: "10px 0" };
|
|
@@ -1050,12 +1118,99 @@ window.__ModuleLoader__.load({
|
|
|
1050
1118
|
),
|
|
1051
1119
|
);
|
|
1052
1120
|
} else {
|
|
1121
|
+
content.push(
|
|
1122
|
+
h(
|
|
1123
|
+
"div",
|
|
1124
|
+
{
|
|
1125
|
+
key: "trash-tools",
|
|
1126
|
+
style: {
|
|
1127
|
+
display: "flex",
|
|
1128
|
+
gap: "8px",
|
|
1129
|
+
alignItems: "center",
|
|
1130
|
+
marginBottom: "8px",
|
|
1131
|
+
flexWrap: "wrap",
|
|
1132
|
+
},
|
|
1133
|
+
},
|
|
1134
|
+
h(
|
|
1135
|
+
Btn,
|
|
1136
|
+
{
|
|
1137
|
+
onClick: () => {
|
|
1138
|
+
/** @type {Record<string, boolean>} */
|
|
1139
|
+
const all = {};
|
|
1140
|
+
for (const item of entries) all[item.entryId] = true;
|
|
1141
|
+
setSelectedTrash(all);
|
|
1142
|
+
},
|
|
1143
|
+
disabled: trashBusy,
|
|
1144
|
+
},
|
|
1145
|
+
props.t("trash.selectAll"),
|
|
1146
|
+
),
|
|
1147
|
+
h(
|
|
1148
|
+
Btn,
|
|
1149
|
+
{ onClick: () => setSelectedTrash({}), disabled: trashBusy },
|
|
1150
|
+
props.t("trash.clear"),
|
|
1151
|
+
),
|
|
1152
|
+
h(
|
|
1153
|
+
Btn,
|
|
1154
|
+
{
|
|
1155
|
+
disabled: trashBusy || selectedEntryIds.length === 0,
|
|
1156
|
+
onClick: doBatchRestore,
|
|
1157
|
+
},
|
|
1158
|
+
props.t("trash.restoreMany", { n: selectedEntryIds.length }),
|
|
1159
|
+
),
|
|
1160
|
+
confirmPurge === "__trashBatchPurge__"
|
|
1161
|
+
? h(
|
|
1162
|
+
Btn,
|
|
1163
|
+
{
|
|
1164
|
+
danger: true,
|
|
1165
|
+
disabled: trashBusy || selectedEntryIds.length === 0,
|
|
1166
|
+
onClick: doBatchPurge,
|
|
1167
|
+
},
|
|
1168
|
+
props.t("trash.purgeManyConfirm", { n: selectedEntryIds.length }),
|
|
1169
|
+
)
|
|
1170
|
+
: h(
|
|
1171
|
+
Btn,
|
|
1172
|
+
{
|
|
1173
|
+
danger: true,
|
|
1174
|
+
disabled: trashBusy || selectedEntryIds.length === 0,
|
|
1175
|
+
onClick: () => setConfirmPurge("__trashBatchPurge__"),
|
|
1176
|
+
},
|
|
1177
|
+
props.t("trash.purgeMany", { n: selectedEntryIds.length }),
|
|
1178
|
+
),
|
|
1179
|
+
),
|
|
1180
|
+
);
|
|
1181
|
+
if (trashMsg) {
|
|
1182
|
+
content.push(
|
|
1183
|
+
h(
|
|
1184
|
+
"div",
|
|
1185
|
+
{
|
|
1186
|
+
key: "trash-msg",
|
|
1187
|
+
style: { color: T.dim, fontSize: "12px", marginBottom: "6px" },
|
|
1188
|
+
},
|
|
1189
|
+
trashMsg,
|
|
1190
|
+
),
|
|
1191
|
+
);
|
|
1192
|
+
}
|
|
1053
1193
|
entries.forEach((/** @type {any} */ entry) => {
|
|
1054
1194
|
content.push(
|
|
1055
1195
|
h(
|
|
1056
1196
|
"div",
|
|
1057
1197
|
{ key: entry.entryId, style: rowStyle },
|
|
1058
|
-
h(
|
|
1198
|
+
h(
|
|
1199
|
+
"label",
|
|
1200
|
+
{ style: { display: "flex", alignItems: "baseline", gap: "8px" } },
|
|
1201
|
+
h("input", {
|
|
1202
|
+
type: "checkbox",
|
|
1203
|
+
checked: Boolean(/** @type {any} */ (selectedTrash)[entry.entryId]),
|
|
1204
|
+
disabled: trashBusy,
|
|
1205
|
+
onChange: () =>
|
|
1206
|
+
setSelectedTrash((/** @type {any} */ current) => ({
|
|
1207
|
+
...current,
|
|
1208
|
+
[entry.entryId]: !current[entry.entryId],
|
|
1209
|
+
})),
|
|
1210
|
+
style: { marginTop: "2px" },
|
|
1211
|
+
}),
|
|
1212
|
+
h("span", { style: { fontWeight: 600 } }, entry.title || entry.sessionId),
|
|
1213
|
+
),
|
|
1059
1214
|
h(
|
|
1060
1215
|
"div",
|
|
1061
1216
|
{ style: { color: T.dim, fontSize: "12px" } },
|
package/lib/operations.js
CHANGED
|
@@ -880,6 +880,50 @@ export function createOperations({ ctx, dataRoot, logger }) {
|
|
|
880
880
|
};
|
|
881
881
|
}
|
|
882
882
|
|
|
883
|
+
/**
|
|
884
|
+
* 批量恢复回收站条目。
|
|
885
|
+
* @param {{ entryIds?: string[], operator?: string }} request
|
|
886
|
+
*/
|
|
887
|
+
async function restoreMany(request = {}) {
|
|
888
|
+
const ids = Array.isArray(request.entryIds) ? request.entryIds : [];
|
|
889
|
+
if (ids.length === 0) throw failure("session-delete/invalid-request", "没有选择任何条目");
|
|
890
|
+
if (ids.length > 50) throw failure("session-delete/invalid-request", "一次最多 50 条");
|
|
891
|
+
/** @type {{ entryId: string, ok: boolean, sessionId?: string, error?: string }[]} */
|
|
892
|
+
const results = [];
|
|
893
|
+
for (const entryId of ids) {
|
|
894
|
+
try {
|
|
895
|
+
const result = await restore(entryId, { operator: request.operator ?? "ui" });
|
|
896
|
+
results.push({ entryId, ok: true, sessionId: result.sessionId });
|
|
897
|
+
} catch (error) {
|
|
898
|
+
results.push({ entryId, ok: false, error: messageOf(error) });
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
const okCount = results.filter((item) => item.ok).length;
|
|
902
|
+
return { ok: okCount === results.length, total: results.length, succeeded: okCount, results };
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
* 批量彻底删除回收站条目。
|
|
907
|
+
* @param {{ entryIds?: string[], operator?: string }} request
|
|
908
|
+
*/
|
|
909
|
+
async function purgeMany(request = {}) {
|
|
910
|
+
const ids = Array.isArray(request.entryIds) ? request.entryIds : [];
|
|
911
|
+
if (ids.length === 0) throw failure("session-delete/invalid-request", "没有选择任何条目");
|
|
912
|
+
if (ids.length > 50) throw failure("session-delete/invalid-request", "一次最多 50 条");
|
|
913
|
+
/** @type {{ entryId: string, ok: boolean, bytes?: number, error?: string }[]} */
|
|
914
|
+
const results = [];
|
|
915
|
+
for (const entryId of ids) {
|
|
916
|
+
try {
|
|
917
|
+
const result = await purge(entryId, { operator: request.operator ?? "ui" });
|
|
918
|
+
results.push({ entryId, ok: true, bytes: result.bytes });
|
|
919
|
+
} catch (error) {
|
|
920
|
+
results.push({ entryId, ok: false, error: messageOf(error) });
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
const okCount = results.filter((item) => item.ok).length;
|
|
924
|
+
return { ok: okCount === results.length, total: results.length, succeeded: okCount, results };
|
|
925
|
+
}
|
|
926
|
+
|
|
883
927
|
/** @param {number} [limit] */
|
|
884
928
|
async function receipts(limit = 50) {
|
|
885
929
|
return { entries: await listReceipts(dataRoot, limit) };
|
|
@@ -888,6 +932,8 @@ export function createOperations({ ctx, dataRoot, logger }) {
|
|
|
888
932
|
return {
|
|
889
933
|
caps,
|
|
890
934
|
health,
|
|
935
|
+
restoreMany,
|
|
936
|
+
purgeMany,
|
|
891
937
|
receipts,
|
|
892
938
|
scanHealth,
|
|
893
939
|
cleanHealth,
|
package/lib/service.js
CHANGED
|
@@ -255,6 +255,30 @@ export class SessionDeleteService extends TypertRemoteService {
|
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
257
|
|
|
258
|
+
/**
|
|
259
|
+
* 批量恢复回收站条目。
|
|
260
|
+
* @param {{ entryIds?: string[] }} request
|
|
261
|
+
*/
|
|
262
|
+
async restoreMany(request) {
|
|
263
|
+
try {
|
|
264
|
+
return await this.ops.restoreMany({ entryIds: request?.entryIds, operator: "ui" });
|
|
265
|
+
} catch (error) {
|
|
266
|
+
rethrow(error);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* 批量彻底删除回收站条目。
|
|
272
|
+
* @param {{ entryIds?: string[] }} request
|
|
273
|
+
*/
|
|
274
|
+
async purgeMany(request) {
|
|
275
|
+
try {
|
|
276
|
+
return await this.ops.purgeMany({ entryIds: request?.entryIds, operator: "ui" });
|
|
277
|
+
} catch (error) {
|
|
278
|
+
rethrow(error);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
258
282
|
/**
|
|
259
283
|
* 最近的操作回执。
|
|
260
284
|
* @param {{ limit?: number }} [request]
|
|
@@ -308,6 +332,8 @@ declareRemote(SessionDeleteService, "list");
|
|
|
308
332
|
declareRemote(SessionDeleteService, "restore");
|
|
309
333
|
declareRemote(SessionDeleteService, "purge");
|
|
310
334
|
declareRemote(SessionDeleteService, "audit");
|
|
335
|
+
declareRemote(SessionDeleteService, "restoreMany");
|
|
336
|
+
declareRemote(SessionDeleteService, "purgeMany");
|
|
311
337
|
declareRemote(SessionDeleteService, "receipts");
|
|
312
338
|
declareRemote(SessionDeleteService, "healthScan");
|
|
313
339
|
declareRemote(SessionDeleteService, "cleanHealth");
|
package/locale/en.json
CHANGED
|
@@ -48,6 +48,12 @@
|
|
|
48
48
|
"confirm.cascade": "Also delete these {n} child session(s) (each goes to trash separately)",
|
|
49
49
|
"health.agentTool": "Agent tool session_delete: {state}",
|
|
50
50
|
"health.agentToolOn": "registered",
|
|
51
|
-
"health.agentToolOff": "not registered (host has no tools runtime)"
|
|
51
|
+
"health.agentToolOff": "not registered (host has no tools runtime)",
|
|
52
|
+
"batch.done": "Done: {ok}/{total} succeeded",
|
|
53
|
+
"trash.selectAll": "Select all",
|
|
54
|
+
"trash.clear": "Clear",
|
|
55
|
+
"trash.restoreMany": "Restore {n}",
|
|
56
|
+
"trash.purgeMany": "Delete {n} permanently",
|
|
57
|
+
"trash.purgeManyConfirm": "Permanently delete {n}? This cannot be undone"
|
|
52
58
|
}
|
|
53
59
|
}
|
package/locale/zh.json
CHANGED
|
@@ -48,6 +48,12 @@
|
|
|
48
48
|
"confirm.cascade": "同时删除这 {n} 个子会话(各自进入回收站,需分别恢复)",
|
|
49
49
|
"health.agentTool": "模型工具 session_delete:{state}",
|
|
50
50
|
"health.agentToolOn": "已注册",
|
|
51
|
-
"health.agentToolOff": "未注册(宿主未提供 tools 运行时)"
|
|
51
|
+
"health.agentToolOff": "未注册(宿主未提供 tools 运行时)",
|
|
52
|
+
"batch.done": "完成:{ok}/{total} 成功",
|
|
53
|
+
"trash.selectAll": "全选",
|
|
54
|
+
"trash.clear": "清空",
|
|
55
|
+
"trash.restoreMany": "批量恢复({n})",
|
|
56
|
+
"trash.purgeMany": "批量彻底删除({n})",
|
|
57
|
+
"trash.purgeManyConfirm": "确认彻底删除 {n} 个?不可恢复"
|
|
52
58
|
}
|
|
53
59
|
}
|