@kangyishuai/dsh-session-delete 0.4.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 +4 -8
- package/README.zh-CN.md +4 -8
- package/lib/client.js +156 -196
- package/lib/operations.js +33 -55
- package/lib/service.js +12 -13
- package/locale/en.json +5 -8
- package/locale/zh.json +5 -8
- 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.4, 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.
|
|
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.
|
|
@@ -99,7 +101,7 @@ v0.1 declares no `engines.dsh` range. Instead there are three layers of defense:
|
|
|
99
101
|
|
|
100
102
|
| Plugin | Verified on DSH | Notes |
|
|
101
103
|
| ------ | ------------------------ | ------------------------------------------------------------------------------------------- |
|
|
102
|
-
| 0.4.
|
|
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. |
|
|
103
105
|
|
|
104
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.
|
|
105
107
|
|
|
@@ -114,12 +116,6 @@ After a DSH upgrade: restart, then open the plugin status (settings → plugins)
|
|
|
114
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 |
|
|
115
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 |
|
|
116
118
|
|
|
117
|
-
## Roadmap (later releases)
|
|
118
|
-
|
|
119
|
-
The following are planned and not implemented yet:
|
|
120
|
-
|
|
121
|
-
- batch deletion (multi-select);
|
|
122
|
-
|
|
123
119
|
## License
|
|
124
120
|
|
|
125
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.4,早期可用。** 已在 DSH 0.2.1-rc.5 上用 `pnpm smoke:session-delete`(24 项端到端断言)加一轮桌面版人工验收。仍是年轻软件,重要数据请自行备份。
|
|
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` 直接打开回收站。删除始终需要菜单 + 确认框,没有一键删除的快捷键。
|
|
@@ -99,7 +101,7 @@ v0.1 没有声明 `engines.dsh` 版本范围,改用三层防线:
|
|
|
99
101
|
|
|
100
102
|
| 插件版本 | 已验证的 DSH 版本 | 说明 |
|
|
101
103
|
| -------- | ------------------------ | -------------------------------------------------------------------------------- |
|
|
102
|
-
| 0.4.
|
|
104
|
+
| 0.4.1 | **0.2.1-rc.5**(桌面版) | `pnpm smoke:session-delete` 24 项断言全绿,并在同一版本桌面版做过人工 GUI 验收。 |
|
|
103
105
|
|
|
104
106
|
目前只在 **macOS** 上验证过。Windows 相关路径(`session.lock` 的 EBUSY/EPERM 重试、宿主在那儿用的命名信号量)代码里有,但**还没实测**。
|
|
105
107
|
|
|
@@ -116,12 +118,6 @@ DSH 升级之后:重启,然后看插件的状态条(设置 → 插件)
|
|
|
116
118
|
| 彻底删除后还残留东西 | 删除回执里列出的残留 | 对回执和审计日志,按回执里的路径手动清理,并把回执附在 issue 里 |
|
|
117
119
|
| 删完之后回收站是空的 | 插件解析到的数据根目录和你的 DSH 不是同一个(`DSH_HOME` / 配置) | 去磁盘上看 `~/.dsh/session-trash/`,再核对插件的 `dataRoot` 配置 |
|
|
118
120
|
|
|
119
|
-
## 计划中(后续版本)
|
|
120
|
-
|
|
121
|
-
下面这些是计划,尚未实现:
|
|
122
|
-
|
|
123
|
-
- 批量删除(多选);
|
|
124
|
-
|
|
125
121
|
## License
|
|
126
122
|
|
|
127
123
|
MIT,见 [LICENSE](./LICENSE)。本插件借鉴了若干社区项目的**设计**(不是代码),来源记在仓库的 [NOTICE](https://github.com/kangyishuai/dsh-plugins/blob/main/NOTICE)。
|
package/lib/client.js
CHANGED
|
@@ -70,15 +70,12 @@ window.__ModuleLoader__.load({
|
|
|
70
70
|
"panel.tabAudit": "审计",
|
|
71
71
|
"panel.tabHealth": "体检",
|
|
72
72
|
"panel.tabReceipts": "回执",
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
"
|
|
78
|
-
"batch.confirm": "确认删除 {n} 个?各自进回收站",
|
|
79
|
-
"batch.running": "正在删除…",
|
|
73
|
+
"trash.selectAll": "全选",
|
|
74
|
+
"trash.clear": "清空",
|
|
75
|
+
"trash.restoreMany": "批量恢复({n})",
|
|
76
|
+
"trash.purgeMany": "批量彻底删除({n})",
|
|
77
|
+
"trash.purgeManyConfirm": "确认彻底删除 {n} 个?不可恢复",
|
|
80
78
|
"batch.done": "完成:{ok}/{total} 成功",
|
|
81
|
-
"batch.live": "运行中",
|
|
82
79
|
"receipts.empty": "还没有操作回执。",
|
|
83
80
|
"receipts.restored": "已移回原位置",
|
|
84
81
|
"health.loading": "正在检查…",
|
|
@@ -133,15 +130,12 @@ window.__ModuleLoader__.load({
|
|
|
133
130
|
"panel.tabAudit": "Audit",
|
|
134
131
|
"panel.tabHealth": "Health",
|
|
135
132
|
"panel.tabReceipts": "Receipts",
|
|
136
|
-
"
|
|
137
|
-
"
|
|
138
|
-
"
|
|
139
|
-
"
|
|
140
|
-
"
|
|
141
|
-
"batch.confirm": "Delete {n} session(s)? Each goes to trash",
|
|
142
|
-
"batch.running": "Deleting…",
|
|
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",
|
|
143
138
|
"batch.done": "Done: {ok}/{total} succeeded",
|
|
144
|
-
"batch.live": "live",
|
|
145
139
|
"receipts.empty": "No operation receipts yet.",
|
|
146
140
|
"receipts.restored": "restored",
|
|
147
141
|
"health.loading": "Checking…",
|
|
@@ -261,7 +255,11 @@ window.__ModuleLoader__.load({
|
|
|
261
255
|
description: props.description,
|
|
262
256
|
footer: props.footer,
|
|
263
257
|
},
|
|
264
|
-
h(
|
|
258
|
+
h(
|
|
259
|
+
Reveal,
|
|
260
|
+
{ style: { maxHeight: "60vh", overflowY: "auto", paddingRight: "4px" } },
|
|
261
|
+
props.children,
|
|
262
|
+
),
|
|
265
263
|
);
|
|
266
264
|
}
|
|
267
265
|
return h(
|
|
@@ -661,6 +659,15 @@ window.__ModuleLoader__.load({
|
|
|
661
659
|
var purgeState = React.useState(null);
|
|
662
660
|
var confirmPurge = purgeState[0];
|
|
663
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];
|
|
664
671
|
var scanState = React.useState(null);
|
|
665
672
|
var scan = scanState[0];
|
|
666
673
|
var setScan = scanState[1];
|
|
@@ -676,30 +683,6 @@ window.__ModuleLoader__.load({
|
|
|
676
683
|
var receiptsState = React.useState(null);
|
|
677
684
|
var receipts = receiptsState[0];
|
|
678
685
|
var setReceipts = receiptsState[1];
|
|
679
|
-
var batchListState = React.useState(null);
|
|
680
|
-
var batchList = batchListState[0];
|
|
681
|
-
var setBatchList = batchListState[1];
|
|
682
|
-
var batchSelectedState = React.useState({});
|
|
683
|
-
var batchSelected = batchSelectedState[0];
|
|
684
|
-
var setBatchSelected = batchSelectedState[1];
|
|
685
|
-
var batchBusyState = React.useState(false);
|
|
686
|
-
var batchBusy = batchBusyState[0];
|
|
687
|
-
var setBatchBusy = batchBusyState[1];
|
|
688
|
-
var batchMsgState = React.useState("");
|
|
689
|
-
var batchMsg = batchMsgState[0];
|
|
690
|
-
var setBatchMsg = batchMsgState[1];
|
|
691
|
-
|
|
692
|
-
const loadBatch = React.useCallback(() => {
|
|
693
|
-
props
|
|
694
|
-
.call("listSessions")
|
|
695
|
-
.then((/** @type {any} */ value) => {
|
|
696
|
-
setBatchList(value && value.sessions ? value.sessions : []);
|
|
697
|
-
})
|
|
698
|
-
.catch((/** @type {any} */ reason) => {
|
|
699
|
-
setBatchList([]);
|
|
700
|
-
setBatchMsg(errorText(reason));
|
|
701
|
-
});
|
|
702
|
-
}, []);
|
|
703
686
|
|
|
704
687
|
const loadReceipts = React.useCallback(() => {
|
|
705
688
|
props
|
|
@@ -825,6 +808,49 @@ window.__ModuleLoader__.load({
|
|
|
825
808
|
});
|
|
826
809
|
};
|
|
827
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
|
+
|
|
828
854
|
var entries = (data && data.entries) || [];
|
|
829
855
|
var readOnly = !!(health && health.readOnly);
|
|
830
856
|
var rowStyle = { borderTop: "1px solid " + T.border, padding: "10px 0" };
|
|
@@ -885,163 +911,10 @@ window.__ModuleLoader__.load({
|
|
|
885
911
|
},
|
|
886
912
|
props.t("panel.tabReceipts"),
|
|
887
913
|
),
|
|
888
|
-
h(
|
|
889
|
-
Btn,
|
|
890
|
-
{
|
|
891
|
-
onClick: () => {
|
|
892
|
-
setTab("batch");
|
|
893
|
-
loadBatch();
|
|
894
|
-
},
|
|
895
|
-
},
|
|
896
|
-
props.t("panel.tabBatch"),
|
|
897
|
-
),
|
|
898
914
|
),
|
|
899
915
|
);
|
|
900
916
|
|
|
901
|
-
if (tab === "
|
|
902
|
-
if (!batchList) {
|
|
903
|
-
content.push(
|
|
904
|
-
h(
|
|
905
|
-
"div",
|
|
906
|
-
{ key: "batch-loading", style: { color: T.dim, padding: "8px 0" } },
|
|
907
|
-
props.t("health.loading"),
|
|
908
|
-
),
|
|
909
|
-
);
|
|
910
|
-
} else if (batchList.length === 0) {
|
|
911
|
-
content.push(
|
|
912
|
-
h(
|
|
913
|
-
"div",
|
|
914
|
-
{ key: "batch-empty", style: { color: T.dim, padding: "8px 0" } },
|
|
915
|
-
props.t("batch.empty"),
|
|
916
|
-
),
|
|
917
|
-
);
|
|
918
|
-
} else {
|
|
919
|
-
const selectedIds = Object.keys(batchSelected).filter(
|
|
920
|
-
(id) => /** @type {any} */ (batchSelected)[id],
|
|
921
|
-
);
|
|
922
|
-
content.push(
|
|
923
|
-
h(
|
|
924
|
-
"div",
|
|
925
|
-
{
|
|
926
|
-
key: "batch-actions",
|
|
927
|
-
style: { display: "flex", gap: "8px", alignItems: "center", marginBottom: "8px" },
|
|
928
|
-
},
|
|
929
|
-
h(
|
|
930
|
-
Btn,
|
|
931
|
-
{
|
|
932
|
-
onClick: () => {
|
|
933
|
-
/** @type {Record<string, boolean>} */
|
|
934
|
-
const all = {};
|
|
935
|
-
for (const item of /** @type {any[]} */ (batchList)) all[item.id] = true;
|
|
936
|
-
setBatchSelected(all);
|
|
937
|
-
},
|
|
938
|
-
},
|
|
939
|
-
props.t("batch.selectAll"),
|
|
940
|
-
),
|
|
941
|
-
h(Btn, { onClick: () => setBatchSelected({}) }, props.t("batch.clear")),
|
|
942
|
-
confirmPurge === "__batch__"
|
|
943
|
-
? h(
|
|
944
|
-
Btn,
|
|
945
|
-
{
|
|
946
|
-
danger: true,
|
|
947
|
-
disabled: batchBusy || selectedIds.length === 0,
|
|
948
|
-
onClick: () => {
|
|
949
|
-
setBatchBusy(true);
|
|
950
|
-
setBatchMsg("");
|
|
951
|
-
props
|
|
952
|
-
.call("trashMany", { sessionIds: selectedIds })
|
|
953
|
-
.then((/** @type {any} */ result) => {
|
|
954
|
-
setBatchBusy(false);
|
|
955
|
-
setConfirmPurge(null);
|
|
956
|
-
setBatchMsg(
|
|
957
|
-
props.t("batch.done", { ok: result.succeeded, total: result.total }),
|
|
958
|
-
);
|
|
959
|
-
for (const item of result.results) {
|
|
960
|
-
if (item.ok) props.onPurged?.(item.id);
|
|
961
|
-
}
|
|
962
|
-
setBatchSelected({});
|
|
963
|
-
loadBatch();
|
|
964
|
-
refresh();
|
|
965
|
-
props.bump?.();
|
|
966
|
-
})
|
|
967
|
-
.catch((/** @type {any} */ reason) => {
|
|
968
|
-
setBatchBusy(false);
|
|
969
|
-
setBatchMsg(errorText(reason));
|
|
970
|
-
});
|
|
971
|
-
},
|
|
972
|
-
},
|
|
973
|
-
props.t("batch.confirm", { n: selectedIds.length }),
|
|
974
|
-
)
|
|
975
|
-
: h(
|
|
976
|
-
Btn,
|
|
977
|
-
{
|
|
978
|
-
danger: true,
|
|
979
|
-
disabled: batchBusy || selectedIds.length === 0,
|
|
980
|
-
onClick: () => setConfirmPurge("__batch__"),
|
|
981
|
-
},
|
|
982
|
-
batchBusy
|
|
983
|
-
? props.t("batch.running")
|
|
984
|
-
: props.t("batch.delete", { n: selectedIds.length }),
|
|
985
|
-
),
|
|
986
|
-
),
|
|
987
|
-
);
|
|
988
|
-
batchList.forEach((/** @type {any} */ item, /** @type {any} */ index) => {
|
|
989
|
-
const checked = Boolean(/** @type {any} */ (batchSelected)[item.id]);
|
|
990
|
-
content.push(
|
|
991
|
-
h(
|
|
992
|
-
"label",
|
|
993
|
-
{
|
|
994
|
-
key: "batch-" + index,
|
|
995
|
-
style: {
|
|
996
|
-
display: "flex",
|
|
997
|
-
alignItems: "baseline",
|
|
998
|
-
gap: "8px",
|
|
999
|
-
borderTop: "1px solid " + T.border,
|
|
1000
|
-
padding: "6px 0",
|
|
1001
|
-
fontSize: "12px",
|
|
1002
|
-
cursor: "pointer",
|
|
1003
|
-
},
|
|
1004
|
-
},
|
|
1005
|
-
h("input", {
|
|
1006
|
-
type: "checkbox",
|
|
1007
|
-
checked: checked,
|
|
1008
|
-
disabled: batchBusy,
|
|
1009
|
-
onChange: () =>
|
|
1010
|
-
setBatchSelected((/** @type {any} */ current) => ({
|
|
1011
|
-
...current,
|
|
1012
|
-
[item.id]: !checked,
|
|
1013
|
-
})),
|
|
1014
|
-
style: { marginTop: "2px" },
|
|
1015
|
-
}),
|
|
1016
|
-
h(
|
|
1017
|
-
"span",
|
|
1018
|
-
{
|
|
1019
|
-
title: item.id,
|
|
1020
|
-
style: {
|
|
1021
|
-
flex: 1,
|
|
1022
|
-
minWidth: 0,
|
|
1023
|
-
overflow: "hidden",
|
|
1024
|
-
textOverflow: "ellipsis",
|
|
1025
|
-
whiteSpace: "nowrap",
|
|
1026
|
-
},
|
|
1027
|
-
},
|
|
1028
|
-
item.title || item.id,
|
|
1029
|
-
),
|
|
1030
|
-
item.live ? h("span", { style: { color: T.danger } }, props.t("batch.live")) : null,
|
|
1031
|
-
),
|
|
1032
|
-
);
|
|
1033
|
-
});
|
|
1034
|
-
}
|
|
1035
|
-
if (batchMsg) {
|
|
1036
|
-
content.push(
|
|
1037
|
-
h(
|
|
1038
|
-
"div",
|
|
1039
|
-
{ key: "batch-msg", style: { color: T.dim, marginTop: "8px", fontSize: "12px" } },
|
|
1040
|
-
batchMsg,
|
|
1041
|
-
),
|
|
1042
|
-
);
|
|
1043
|
-
}
|
|
1044
|
-
} else if (tab === "receipts") {
|
|
917
|
+
if (tab === "receipts") {
|
|
1045
918
|
if (!receipts || receipts.length === 0) {
|
|
1046
919
|
content.push(
|
|
1047
920
|
h(
|
|
@@ -1245,12 +1118,99 @@ window.__ModuleLoader__.load({
|
|
|
1245
1118
|
),
|
|
1246
1119
|
);
|
|
1247
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
|
+
}
|
|
1248
1193
|
entries.forEach((/** @type {any} */ entry) => {
|
|
1249
1194
|
content.push(
|
|
1250
1195
|
h(
|
|
1251
1196
|
"div",
|
|
1252
1197
|
{ key: entry.entryId, style: rowStyle },
|
|
1253
|
-
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
|
+
),
|
|
1254
1214
|
h(
|
|
1255
1215
|
"div",
|
|
1256
1216
|
{ style: { color: T.dim, fontSize: "12px" } },
|
package/lib/operations.js
CHANGED
|
@@ -880,70 +880,48 @@ export function createOperations({ ctx, dataRoot, logger }) {
|
|
|
880
880
|
};
|
|
881
881
|
}
|
|
882
882
|
|
|
883
|
-
/**
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
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
|
+
}
|
|
887
900
|
}
|
|
888
|
-
const
|
|
889
|
-
|
|
890
|
-
const id = String(entry?.id ?? entry?.header?.id ?? "");
|
|
891
|
-
return {
|
|
892
|
-
id,
|
|
893
|
-
title: typeof entry?.header?.title === "string" ? entry.header.title : null,
|
|
894
|
-
cwd: typeof entry?.header?.cwd === "string" ? entry.header.cwd : null,
|
|
895
|
-
live: caps.services.sessions?.get?.(id) !== undefined,
|
|
896
|
-
};
|
|
897
|
-
});
|
|
898
|
-
out.sort((/** @type {any} */ a, /** @type {any} */ b) =>
|
|
899
|
-
String(b.title ?? b.id).localeCompare(String(a.title ?? a.id)),
|
|
900
|
-
);
|
|
901
|
-
return { sessions: out.filter((/** @type {any} */ item) => item.id.length > 0) };
|
|
901
|
+
const okCount = results.filter((item) => item.ok).length;
|
|
902
|
+
return { ok: okCount === results.length, total: results.length, succeeded: okCount, results };
|
|
902
903
|
}
|
|
903
904
|
|
|
904
905
|
/**
|
|
905
|
-
*
|
|
906
|
-
* @param {{
|
|
906
|
+
* 批量彻底删除回收站条目。
|
|
907
|
+
* @param {{ entryIds?: string[], operator?: string }} request
|
|
907
908
|
*/
|
|
908
|
-
async function
|
|
909
|
-
const ids = Array.isArray(request.
|
|
910
|
-
if (ids.length === 0) throw failure("session-delete/invalid-request", "
|
|
911
|
-
if (ids.length > 50) throw failure("session-delete/invalid-request", "一次最多 50
|
|
912
|
-
/** @type {{
|
|
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 }[]} */
|
|
913
914
|
const results = [];
|
|
914
|
-
for (const
|
|
915
|
+
for (const entryId of ids) {
|
|
915
916
|
try {
|
|
916
|
-
const result = await
|
|
917
|
-
|
|
918
|
-
operator: request.operator ?? "ui",
|
|
919
|
-
});
|
|
920
|
-
results.push({ id, ok: true, entryId: result.entryId, receiptId: result.receiptId });
|
|
917
|
+
const result = await purge(entryId, { operator: request.operator ?? "ui" });
|
|
918
|
+
results.push({ entryId, ok: true, bytes: result.bytes });
|
|
921
919
|
} catch (error) {
|
|
922
|
-
|
|
923
|
-
results.push({
|
|
924
|
-
id,
|
|
925
|
-
ok: false,
|
|
926
|
-
code: typeof raw?.code === "string" ? raw.code : "error",
|
|
927
|
-
error: messageOf(error),
|
|
928
|
-
});
|
|
920
|
+
results.push({ entryId, ok: false, error: messageOf(error) });
|
|
929
921
|
}
|
|
930
922
|
}
|
|
931
923
|
const okCount = results.filter((item) => item.ok).length;
|
|
932
|
-
|
|
933
|
-
action: "trash-many",
|
|
934
|
-
at: new Date().toISOString(),
|
|
935
|
-
requested: ids.length,
|
|
936
|
-
succeeded: okCount,
|
|
937
|
-
failed: results.length - okCount,
|
|
938
|
-
results,
|
|
939
|
-
});
|
|
940
|
-
return {
|
|
941
|
-
ok: okCount === results.length,
|
|
942
|
-
total: results.length,
|
|
943
|
-
succeeded: okCount,
|
|
944
|
-
results,
|
|
945
|
-
receiptId,
|
|
946
|
-
};
|
|
924
|
+
return { ok: okCount === results.length, total: results.length, succeeded: okCount, results };
|
|
947
925
|
}
|
|
948
926
|
|
|
949
927
|
/** @param {number} [limit] */
|
|
@@ -954,8 +932,8 @@ export function createOperations({ ctx, dataRoot, logger }) {
|
|
|
954
932
|
return {
|
|
955
933
|
caps,
|
|
956
934
|
health,
|
|
957
|
-
|
|
958
|
-
|
|
935
|
+
restoreMany,
|
|
936
|
+
purgeMany,
|
|
959
937
|
receipts,
|
|
960
938
|
scanHealth,
|
|
961
939
|
cleanHealth,
|
package/lib/service.js
CHANGED
|
@@ -255,26 +255,25 @@ export class SessionDeleteService extends TypertRemoteService {
|
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
257
|
|
|
258
|
-
/**
|
|
259
|
-
|
|
258
|
+
/**
|
|
259
|
+
* 批量恢复回收站条目。
|
|
260
|
+
* @param {{ entryIds?: string[] }} request
|
|
261
|
+
*/
|
|
262
|
+
async restoreMany(request) {
|
|
260
263
|
try {
|
|
261
|
-
return await this.ops.
|
|
264
|
+
return await this.ops.restoreMany({ entryIds: request?.entryIds, operator: "ui" });
|
|
262
265
|
} catch (error) {
|
|
263
266
|
rethrow(error);
|
|
264
267
|
}
|
|
265
268
|
}
|
|
266
269
|
|
|
267
270
|
/**
|
|
268
|
-
*
|
|
269
|
-
* @param {{
|
|
271
|
+
* 批量彻底删除回收站条目。
|
|
272
|
+
* @param {{ entryIds?: string[] }} request
|
|
270
273
|
*/
|
|
271
|
-
async
|
|
274
|
+
async purgeMany(request) {
|
|
272
275
|
try {
|
|
273
|
-
return await this.ops.
|
|
274
|
-
sessionIds: request?.sessionIds,
|
|
275
|
-
cascade: request?.cascade === true,
|
|
276
|
-
operator: "ui",
|
|
277
|
-
});
|
|
276
|
+
return await this.ops.purgeMany({ entryIds: request?.entryIds, operator: "ui" });
|
|
278
277
|
} catch (error) {
|
|
279
278
|
rethrow(error);
|
|
280
279
|
}
|
|
@@ -333,8 +332,8 @@ declareRemote(SessionDeleteService, "list");
|
|
|
333
332
|
declareRemote(SessionDeleteService, "restore");
|
|
334
333
|
declareRemote(SessionDeleteService, "purge");
|
|
335
334
|
declareRemote(SessionDeleteService, "audit");
|
|
336
|
-
declareRemote(SessionDeleteService, "
|
|
337
|
-
declareRemote(SessionDeleteService, "
|
|
335
|
+
declareRemote(SessionDeleteService, "restoreMany");
|
|
336
|
+
declareRemote(SessionDeleteService, "purgeMany");
|
|
338
337
|
declareRemote(SessionDeleteService, "receipts");
|
|
339
338
|
declareRemote(SessionDeleteService, "healthScan");
|
|
340
339
|
declareRemote(SessionDeleteService, "cleanHealth");
|
package/locale/en.json
CHANGED
|
@@ -49,14 +49,11 @@
|
|
|
49
49
|
"health.agentTool": "Agent tool session_delete: {state}",
|
|
50
50
|
"health.agentToolOn": "registered",
|
|
51
51
|
"health.agentToolOff": "not registered (host has no tools runtime)",
|
|
52
|
-
"panel.tabBatch": "Batch",
|
|
53
|
-
"batch.empty": "No sessions to delete.",
|
|
54
|
-
"batch.selectAll": "Select all",
|
|
55
|
-
"batch.clear": "Clear",
|
|
56
|
-
"batch.delete": "Delete {n} selected",
|
|
57
|
-
"batch.confirm": "Delete {n} session(s)? Each goes to trash",
|
|
58
|
-
"batch.running": "Deleting…",
|
|
59
52
|
"batch.done": "Done: {ok}/{total} succeeded",
|
|
60
|
-
"
|
|
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"
|
|
61
58
|
}
|
|
62
59
|
}
|
package/locale/zh.json
CHANGED
|
@@ -49,14 +49,11 @@
|
|
|
49
49
|
"health.agentTool": "模型工具 session_delete:{state}",
|
|
50
50
|
"health.agentToolOn": "已注册",
|
|
51
51
|
"health.agentToolOff": "未注册(宿主未提供 tools 运行时)",
|
|
52
|
-
"panel.tabBatch": "批量",
|
|
53
|
-
"batch.empty": "没有可删除的会话。",
|
|
54
|
-
"batch.selectAll": "全选",
|
|
55
|
-
"batch.clear": "清空",
|
|
56
|
-
"batch.delete": "批量删除({n})",
|
|
57
|
-
"batch.confirm": "确认删除 {n} 个?各自进回收站",
|
|
58
|
-
"batch.running": "正在删除…",
|
|
59
52
|
"batch.done": "完成:{ok}/{total} 成功",
|
|
60
|
-
"
|
|
53
|
+
"trash.selectAll": "全选",
|
|
54
|
+
"trash.clear": "清空",
|
|
55
|
+
"trash.restoreMany": "批量恢复({n})",
|
|
56
|
+
"trash.purgeMany": "批量彻底删除({n})",
|
|
57
|
+
"trash.purgeManyConfirm": "确认彻底删除 {n} 个?不可恢复"
|
|
61
58
|
}
|
|
62
59
|
}
|