dsh-delete-session 0.3.0 → 0.3.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 +6 -0
- package/package.json +1 -1
- package/src/client.js +50 -3
- package/test/checkbox.dom.test.js +769 -687
package/README.md
CHANGED
|
@@ -162,6 +162,12 @@ MIT
|
|
|
162
162
|
|
|
163
163
|
## 修复记录
|
|
164
164
|
|
|
165
|
+
**(v0.3.1)** —— 批量删除也会处理产出文件了。
|
|
166
|
+
|
|
167
|
+
- **批量删除原来完全不碰产出文件**:单删会带上 `quarantine`,批量那条却调 `postDelete(id)` 什么都不传,宿主按缺省当「不动文件」。于是用户明明开着「产出文件默认全部进隔离夹」,批量删时文件**原地留着**,而且没有任何提示——看起来像做了,其实没做。现在两条路径共用 `quarantinePlan()`。
|
|
168
|
+
- **批量也会报文件数**:「已删除 N 个会话,M 个文件已移入隔离夹」;有失败则分开报成功与失败数。原来是干巴巴一句「已删除 N 个会话」,看不出文件去哪了。
|
|
169
|
+
- **询问模式下批量会明说**:勾着「产出文件先询问」时批量删不了清单(100 个会话挨个弹窗不现实),所以文件确实没处理。现在补一句提示,告诉用户要么单个删、要么在插件页改成自动隔离——而不是让它静默过去。
|
|
170
|
+
- 顺带修了测试夹具跨用例串扰:批量成功后排的 2.5 秒 `settlePendingSoon` 定时器会活到下一个用例,用**旧插件的闭包**去装饰**新用例的 DOM**,导致三条毫不相关的用例随机变红。现在每条用例开始前清掉遗留定时器,连跑 5 次稳定。
|
|
165
171
|
**(v0.3.0)** —— 多选支持按工作区全选,也能一次选中全部会话。
|
|
166
172
|
|
|
167
173
|
- **两个全选框**:`工作区 N` 那一行多一个框,选中**所有**会话;每个工作区标题行(含「未分组」)各多一个框,只选中**该组**。点一下全选,再点一下清空。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-delete-session",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Delete sessions from the DSH Web sidebar: adds a Delete action to the session row menu with a risk-consent dialog, sends the session log, workspace accounting and live session state to the system trash (or removes them outright), and, when opted in, quarantines the files the conversation produced.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
package/src/client.js
CHANGED
|
@@ -59,6 +59,9 @@ window.__ModuleLoader__.load({
|
|
|
59
59
|
deleteSelected: '删除',
|
|
60
60
|
batchDone: (n) => `已删除 ${n} 个会话`,
|
|
61
61
|
batchPartial: (ok, fail) => `已删除 ${ok} 个,${fail} 个失败`,
|
|
62
|
+
batchDoneQuarantine: (n, m) => `已删除 ${n} 个会话,${m} 个文件已移入隔离夹`,
|
|
63
|
+
batchDoneQuarantineFailed: (n, ok, fail) => `已删除 ${n} 个会话,隔离 ${ok} 个、${fail} 个失败`,
|
|
64
|
+
batchAskArtifacts: '这批会话的产出文件没有处理:批量删除不列逐文件清单。要处理它们,请单个删除,或在插件页改成「产出文件默认全部进隔离夹」。',
|
|
62
65
|
batchFailed: '批量删除失败:',
|
|
63
66
|
pageAsk: '删除时询问',
|
|
64
67
|
pageRecycle: '删除至回收站',
|
|
@@ -165,6 +168,9 @@ window.__ModuleLoader__.load({
|
|
|
165
168
|
deleteSelected: 'Delete',
|
|
166
169
|
batchDone: (n) => `Deleted ${n} session(s)`,
|
|
167
170
|
batchPartial: (ok, fail) => `Deleted ${ok}, ${fail} failed`,
|
|
171
|
+
batchDoneQuarantine: (n, m) => `Deleted ${n} session(s), ${m} file(s) moved to quarantine`,
|
|
172
|
+
batchDoneQuarantineFailed: (n, ok, fail) => `Deleted ${n} session(s), ${ok} quarantined and ${fail} failed`,
|
|
173
|
+
batchAskArtifacts: 'The produced files of these sessions were left alone: a batch has no per-file checklist. Delete them one by one, or switch the plugin page to "move every produced file to quarantine".',
|
|
168
174
|
batchFailed: 'Batch delete failed: ',
|
|
169
175
|
pageAsk: 'Ask before deleting',
|
|
170
176
|
pageRecycle: 'Delete to the Recycle Bin',
|
|
@@ -268,6 +274,9 @@ window.__ModuleLoader__.load({
|
|
|
268
274
|
deleteSelected: 'Удалить',
|
|
269
275
|
batchDone: (n) => `Удалено сессий: ${n}`,
|
|
270
276
|
batchPartial: (ok, fail) => `Удалено ${ok}, не удалось ${fail}`,
|
|
277
|
+
batchDoneQuarantine: (n, m) => `Удалено сессий: ${n}, файлов в карантине: ${m}`,
|
|
278
|
+
batchDoneQuarantineFailed: (n, ok, fail) => `Удалено сессий: ${n}, в карантине ${ok}, не удалось ${fail}`,
|
|
279
|
+
batchAskArtifacts: 'Файлы этих сессий не обработаны: пакетное удаление не показывает список файлов. Удаляйте по одному или переключите страницу плагина на «все созданные файлы в карантин». ',
|
|
271
280
|
batchFailed: 'Массовое удаление не удалось: ',
|
|
272
281
|
pageAsk: 'Спрашивать перед удалением',
|
|
273
282
|
pageRecycle: 'Удалять в корзину',
|
|
@@ -598,6 +607,20 @@ window.__ModuleLoader__.load({
|
|
|
598
607
|
return () => { prefListeners.delete(listener) }
|
|
599
608
|
}
|
|
600
609
|
|
|
610
|
+
/**
|
|
611
|
+
* The `quarantine` payload a delete should carry, or undefined for "do not
|
|
612
|
+
* touch any file".
|
|
613
|
+
*
|
|
614
|
+
* Only `auto` mode can answer this without a dialog: asking means handing the
|
|
615
|
+
* user a per-file checklist, which a batch of sessions has nowhere to put.
|
|
616
|
+
* The batch path used to skip this entirely, so a user who had switched the
|
|
617
|
+
* feature on got a silent no-op instead of a quarantine.
|
|
618
|
+
*/
|
|
619
|
+
function quarantinePlan() {
|
|
620
|
+
if (artifactsOff() || !artifactsAuto()) return undefined
|
|
621
|
+
return { scope: artifactScope() }
|
|
622
|
+
}
|
|
623
|
+
|
|
601
624
|
/** Whether the produced-files feature is off. Off unless explicitly enabled. */
|
|
602
625
|
function artifactsOff() {
|
|
603
626
|
return readPref(OFF_KEY, '1') !== '0'
|
|
@@ -1654,6 +1677,15 @@ window.__ModuleLoader__.load({
|
|
|
1654
1677
|
for (const id of ids) state.pending.add(id)
|
|
1655
1678
|
publish()
|
|
1656
1679
|
|
|
1680
|
+
// The same switch the single path honours; without this every request went
|
|
1681
|
+
// out with no `quarantine` field and the files stayed where they were.
|
|
1682
|
+
const quarantine = quarantinePlan()
|
|
1683
|
+
// The feature is on but `auto` is off: the user expects files to be handled
|
|
1684
|
+
// and a batch cannot show the per-file checklist. Say so afterwards rather
|
|
1685
|
+
// than pretending the files were dealt with.
|
|
1686
|
+
const askOnly = !artifactsOff() && !artifactsAuto()
|
|
1687
|
+
let movedFiles = 0
|
|
1688
|
+
let failedFiles = 0
|
|
1657
1689
|
const failedIds = []
|
|
1658
1690
|
let cursor = 0
|
|
1659
1691
|
const worker = async () => {
|
|
@@ -1663,7 +1695,12 @@ window.__ModuleLoader__.load({
|
|
|
1663
1695
|
if (index >= ids.length) return
|
|
1664
1696
|
const id = ids[index]
|
|
1665
1697
|
try {
|
|
1666
|
-
await postDelete(id)
|
|
1698
|
+
const result = await postDelete(id, quarantine)
|
|
1699
|
+
const outcome = result && result.quarantine ? result.quarantine : null
|
|
1700
|
+
if (outcome !== null) {
|
|
1701
|
+
movedFiles += outcome.moved.length
|
|
1702
|
+
failedFiles += outcome.failed.length
|
|
1703
|
+
}
|
|
1667
1704
|
state.batch.done += 1
|
|
1668
1705
|
} catch {
|
|
1669
1706
|
state.batch.failed += 1
|
|
@@ -1681,12 +1718,22 @@ window.__ModuleLoader__.load({
|
|
|
1681
1718
|
const ok = state.batch ? state.batch.done : 0
|
|
1682
1719
|
state.batch = null
|
|
1683
1720
|
if (failed === 0) {
|
|
1684
|
-
|
|
1721
|
+
// The files are reported with the count, so a user who moved a hundred
|
|
1722
|
+
// of them sees that number instead of a bare "deleted".
|
|
1723
|
+
if (failedFiles > 0) {
|
|
1724
|
+
toast(t('batchDoneQuarantineFailed', ok, movedFiles, failedFiles), true)
|
|
1725
|
+
} else if (movedFiles > 0) {
|
|
1726
|
+
toast(t('batchDoneQuarantine', ok, movedFiles))
|
|
1727
|
+
} else {
|
|
1728
|
+
toast(t('batchDone', ok))
|
|
1729
|
+
}
|
|
1730
|
+
if (askOnly) toast(t('batchAskArtifacts'), true)
|
|
1685
1731
|
exitSelection({ keepPending: true })
|
|
1686
1732
|
settlePendingSoon()
|
|
1687
1733
|
} else {
|
|
1688
1734
|
for (const id of failedIds) state.selected.add(id)
|
|
1689
1735
|
toast(t('batchPartial', ok, failed), true)
|
|
1736
|
+
if (askOnly) toast(t('batchAskArtifacts'), true)
|
|
1690
1737
|
publish()
|
|
1691
1738
|
}
|
|
1692
1739
|
refreshList()
|
|
@@ -1765,7 +1812,7 @@ window.__ModuleLoader__.load({
|
|
|
1765
1812
|
// and the menu row forces the dialog in that case. With the feature off no
|
|
1766
1813
|
// quarantine field is sent at all, keeping the request identical to the
|
|
1767
1814
|
// version that predates the feature.
|
|
1768
|
-
const quarantine =
|
|
1815
|
+
const quarantine = quarantinePlan()
|
|
1769
1816
|
postDelete(info.sessionId, quarantine)
|
|
1770
1817
|
.then((result) => {
|
|
1771
1818
|
const outcome = result && result.quarantine ? result.quarantine : null
|