Repository navigation
Expand file tree
/
Copy pathclient.js
More file actions
3673 lines (3553 loc) · 168 KB
/
Copy pathclient.js
File metadata and controls
3673 lines (3553 loc) · 168 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
window.__ModuleLoader__.load({
id: '@wangxiaocuo/dsh-session-trash',
factory(require) {
const React = require('react')
const h = React.createElement
const NS = 'sessionTrash'
const CSRF_HEADER = 'X-DSH-Session-Trash'
const MENU_ID = 'session-trash.move'
const SECTION_ID = 'session-trash'
const PREFLIGHT_TIMEOUT_MS = 800
/** Hard budget for one ordinary trash write request. */
const MUTATION_TIMEOUT_MS = 30_000
/** Reclaim scans and batched deletion can take much longer. */
const RECLAIM_TIMEOUT_MS = 120_000
/** Hard budget for one `/state` read. */
const STATE_TIMEOUT_MS = 15_000
const DAY_MS = 86_400_000
/** Rows per page in the trash list. */
const PAGE_SIZE = 50
/** How often the page re-checks workspace availability while visible. */
const WORKSPACE_POLL_MS = 10_000
/** Hard budget for one lightweight workspace probe. */
const WORKSPACE_POLL_TIMEOUT_MS = 5_000
/** A row counts as “expiring soon” from this many days before expiry. */
const EXPIRING_DAYS = 3
/** Filter identifiers in their sidebar order. */
const FILTERS = ['all', 'workspace-exists', 'workspace-missing', 'expiring']
/** Sort options in their menu order. */
const SORT_OPTIONS = [
{ value: 'trashed', key: 'sortTrashed' },
{ value: 'title', key: 'sortTitle' },
{ value: 'size', key: 'sortSize' },
{ value: 'expires', key: 'sortExpires' },
]
/** Locale keys for each filter label. */
const FILTER_LABEL_KEYS = {
all: 'filterAll',
'workspace-exists': 'filterWorkspaceExists',
'workspace-missing': 'filterWorkspaceMissing',
expiring: 'filterExpiring',
}
/**
* Preflight refusals the user can act on themselves. Those keep a visible
* menu entry that explains the refusal instead of hiding it.
*/
/** Host `lastErrorCode` values mapped to owner-facing messages. */
const LAST_ERROR_KEYS = {
TRASH_COPY_MISSING: 'lastErrorTrashCopyMissing',
TRASH_COPY_MISSING_MEMBERS: 'lastErrorTrashCopyMissingMembers',
TRASH_OBJECT_MISSING: 'lastErrorTrashObjectMissing',
PURGE_FAILED: 'lastErrorPurgeFailed',
RESTORE_INVISIBLE: 'lastErrorRestoreInvisible',
MOVE_UNSETTLED: 'lastErrorMoveUnsettled',
SOURCE_CONFLICT: 'lastErrorSourceConflict',
INDEX_WRITE_FAILED: 'lastErrorIndexWriteFailed',
IO_ERROR: 'lastErrorIo',
}
const MOVE_BLOCKED_KEYS = {
SESSION_LIVE: { label: 'moveBlockedLive', toast: 'blockedLiveToast' },
SESSION_ACTIVE: { label: 'moveBlockedActive', toast: 'blockedActiveToast' },
SESSION_HAS_DESCENDANTS: {
label: 'moveBlockedDescendants',
toast: 'blockedDescendantsToast',
},
}
/** Open trash views subscribe here so one successful mutation refreshes them all. */
const revisionListeners = new Set()
/** Cross-window channel name; same-origin tabs refresh each other. */
const REVISION_CHANNEL_NAME = 'dsh-session-trash/revision'
/** Lazily created BroadcastChannel shared by every view in this tab. */
let revisionChannel = null
let revisionChannelTried = false
/**
* Open the cross-window revision channel once, when the platform supports it.
* @returns {void}
*/
function ensureRevisionChannel() {
if (revisionChannelTried) return
revisionChannelTried = true
const Ctor = typeof window === 'undefined' ? undefined : window.BroadcastChannel
if (typeof Ctor !== 'function') return
try {
revisionChannel = new Ctor(REVISION_CHANNEL_NAME)
revisionChannel.addEventListener('message', (event) => {
if (event === null || event === undefined) return
const data = event.data
if (data === null || typeof data !== 'object') return
if (data.type === 'revision') notifyRevisionListeners()
})
} catch {
revisionChannel = null
}
}
/**
* @returns {void}
*/
function notifyRevisionListeners() {
for (const listener of [...revisionListeners]) {
try {
listener()
} catch (error) {
console.error('[dsh-session-trash] revision listener failed', error)
}
}
}
/**
* Notify every mounted trash view in this tab and across same-origin tabs.
* @returns {void}
*/
function bumpRevision() {
ensureRevisionChannel()
notifyRevisionListeners()
if (revisionChannel === null) return
try {
revisionChannel.postMessage({ type: 'revision' })
} catch {
// A closed channel must never break the mutation that triggered it.
}
}
/**
* @param {() => void} listener refresh callback.
* @returns {() => void} unsubscribe.
*/
function subscribeRevision(listener) {
ensureRevisionChannel()
revisionListeners.add(listener)
return () => {
revisionListeners.delete(listener)
}
}
const zh = {
nav: '回收站',
title: '回收站',
subtitle: '已删除的会话会在这里保留 {days} 天,到期后自动永久删除。',
refresh: '刷新',
retry: '重试',
cleanupExpired: '清理已过期',
cleaning: '正在清理…',
statsCountOne: '{count} 个会话',
statsCountOther: '{count} 个会话',
statsSize: '日志 {size}',
logSize: '日志 {size}',
logSizeHint: '仅会话日志,不含附件和图片',
storageSummary: '本机会话数据 {total}:日志 {logs} · 附件 {attachments} · 缓存 {cache}',
storageSweepable: '可清扫 {size}',
storageOrphan: '其中 {size} 无引用',
storageScanPartial: '引用扫描不完整',
storageScanUnavailable: '引用扫描不可用',
storageIndexPartial: '附件统计不完整',
reclaimOpen: '清理无引用附件…',
reclaimTitle: '清理无引用附件?',
reclaimScanning: '正在扫描无引用附件…',
reclaimSummaryOne: '将删除 {count} 个附件对象,释放 {size}。',
reclaimSummaryOther: '将删除 {count} 个附件对象,释放 {size}。',
reclaimBody: '只删除超过 24 小时、没有任何会话引用的对象;共享附件、会话日志、投影缓存和搜索索引不会被删除。此操作不可恢复。',
reclaimHint: '建议先关闭其他 DSH 窗口;清理期间如有新会话或新引用,操作会自动停止。',
reclaimConfirmLabel: '输入「{phrase}」以确认',
reclaimConfirmPhrase: '删除附件',
reclaimConfirm: '永久删除',
reclaimDeleting: '正在删除…',
reclaimDoneOne: '已删除 {count} 个无引用附件,释放 {size}。',
reclaimDoneOther: '已删除 {count} 个无引用附件,释放 {size}。',
reclaimDoneSkipped: '已删除 {count} 个无引用附件,释放 {size};跳过 {skipped} 个。',
reclaimStopped: '有会话更新,清理已停止;其余对象未删除。',
reclaimNothing: '没有超过 24 小时的无引用附件。',
reclaimMissing: '有 {count} 条日志缺失的回收站记录,无法判断其附件引用。先移除这些记录再清理。',
reclaimForgetMissing: '移除缺失记录并继续',
reclaimBusy: '回收站正在整理,请稍后重试。',
reclaimScanUnavailable: '当前 Node 运行时没有 zstd 解码器,无法安全扫描附件引用。',
reclaimScanIncomplete: '附件引用扫描不完整,无法安全清理。请重试或检查 DSH 日志。',
reclaimStale: '会话有更新,计划已失效,请重新预览。',
reclaimExpired: '清理计划已过期,请重新预览。',
reclaimRetry: '重新预览',
searchLabel: '搜索回收站',
searchPlaceholder: '搜索标题、Session ID 或原始工作区',
searchClear: '清除搜索',
resultsCount: '显示 {shown} / {total} 个会话',
selectRow: '选择「{title}」',
selectAll: '全选本页可选会话',
selectedCount: '已选择 {count} 个会话',
clearSelection: '取消选择',
batchRestore: '恢复选中',
batchRestoring: '正在恢复…',
batchRestoreDoneOne: '已恢复 {count} 个会话',
batchRestoreDoneOther: '已恢复 {count} 个会话',
batchRestorePartial: '已恢复 {restored} 个会话,{failed} 个失败',
sortLabel: '排序方式',
sortTrashed: '按移入时间(最新在前)',
sortTitle: '按标题',
sortSize: '按大小(最大在前)',
sortExpires: '按到期时间(最早在前)',
expandMembers: '展开子会话',
collapseMembers: '收起子会话',
memberParent: '父会话',
memberSubagent: '子会话',
filterLabel: '筛选回收站',
filterAll: '全部',
filterWorkspaceExists: '可恢复回工作区',
filterWorkspaceMissing: '需孤儿恢复',
filterExpiring: '即将到期',
filterResults: '已筛选出 {count} 个会话',
noResultsTitle: '没有匹配的会话',
noResultsBody: '试试其他关键词,或清除搜索和筛选条件。',
clearFilters: '清除筛选',
paginationLabel: '回收站分页',
previousPage: '上一页',
nextPage: '下一页',
pageInfo: '第 {page} / {total} 页',
pageAnnouncement: '第 {page} 页,共 {total} 页',
nextSweep: '下次自动清理:{date}',
nextSweepUnknown: '下次自动清理:打开页面时检查',
autoCleanupOff: '自动清理已关闭',
autoCleanupBanner: '自动清理已关闭;过期会话不会自动删除,仍可手动永久删除。',
emptyTitle: '回收站为空',
emptyBody: '在侧边栏右键会话,选择「移入回收站」。',
loading: '正在加载…',
errorNetwork: '无法连接到回收站服务。',
errorTimeout: '请求超时,请重试。',
errorUnauthorized: '连接已失效,请刷新页面。',
errorForbidden: '当前身份无权访问回收站。',
errorGeneric: '回收站加载失败。',
corruptBanner: '回收站索引损坏,已进入保护模式。现有会话不会被自动修改。',
recoveredBanner: '回收站索引已从备份恢复。',
unindexedBanner: '回收站目录中有 {count} 个未索引对象,插件不会自动删除它们。',
orphansClean: '清理空目录',
orphansTitle: '清理空的无主对象?',
orphansBody: '只删除回收站中不含会话日志的残留目录;可能含日志的无主对象会保留。',
orphansConfirm: '清理空目录',
orphansDoneOne: '已清理 {count} 个空的无主对象',
orphansDoneOther: '已清理 {count} 个空的无主对象',
orphansNone: '没有可安全清理的空目录',
rebuild: '尝试重建索引',
rebuilding: '正在重建…',
rebuildDone: '索引已重建,共 {count} 个条目',
rebuildDoneUnindexed: '索引已重建,共 {count} 个条目;{unindexed} 个未索引对象已保留',
listLabel: '已删除的会话',
noWorkspace: '未分组',
workspaceLabel: '原工作区:',
unknownWorkspace: '未知工作区',
trashedAtLabel: '移入时间',
notScheduled: '不参与自动清理',
expiresOn: '将于 {date} 清理',
badgeMissing: '文件缺失',
badgeWorkspaceMissing: '工作区缺失',
badgeWorkspaceRemoved: '工作区已移除',
badgeMigration: '需要迁移',
badgeExpiring: '即将到期',
badgeExpired: '已过期',
badgeSubagentsOne: '含 {count} 个子会话',
badgeSubagentsOther: '含 {count} 个子会话',
stateTrashing: '正在移入…',
stateRestoring: '正在恢复…',
statePurging: '正在删除…',
actionRestore: '恢复',
actionRestoreFor: '恢复「{title}」',
actionMoreFor: '「{title}」的更多操作',
actionRestoreOrphan: '恢复为孤儿会话',
actionReveal: '在文件管理器中显示',
actionRevealDisabled: '原工作区已不存在',
actionCopyId: '复制 Session ID',
actionForget: '从索引移除',
actionPurge: '永久删除',
dialogCancel: '取消',
orphanTitle: '原工作区不存在',
orphanBody: '「{path}」已不存在。恢复为孤儿会话后,会话会出现在「未分组」,不会自动创建目录。',
orphanRemovedTitle: '原工作区已移除',
orphanRemovedBody:
'「{path}」仍在磁盘上,但已不在 DSH 的工作区列表中,无法把会话挂回原工作区。恢复为孤儿会话后,会话会出现在「未分组」,不会改动该目录。',
orphanConfirm: '恢复为孤儿会话',
purgeTitle: '永久删除「{title}」的会话日志?',
purgeBody: '此操作不可撤销。会话日志和投影缓存会一并删除;附件和图片会保留,搜索索引会在下次搜索时自动剔除该会话。',
purgeConfirm: '永久删除',
purgeAll: '永久删除全部',
purgingAll: '正在删除…',
purgeAllTitle: '永久删除回收站中的全部 {count} 个会话?',
purgeAllBody: '此操作不可撤销。会话日志和投影缓存会一并删除;附件和图片会保留,搜索索引会在下次搜索时自动剔除这些会话。',
purgeAllConfirm: '全部永久删除',
purgeAllDoneOne: '已永久删除 {count} 个会话,释放 {size}',
purgeAllDoneOther: '已永久删除 {count} 个会话,释放 {size}',
purgeAllDonePlainOne: '已永久删除 {count} 个会话',
purgeAllDonePlainOther: '已永久删除 {count} 个会话',
purgeAllNone: '回收站中没有可删除的会话',
purgeAllPartial: '批量删除完成:成功 {removed} 个,失败 {failed} 个,释放 {size}。',
purgeAllPartialPlain: '批量删除完成:成功 {removed} 个,失败 {failed} 个。',
forgetTitle: '从回收站列表移除这条缺失记录?',
forgetBody: '不会删除任何文件;仅移除索引中的这条记录。',
forgetConfirm: '从索引移除',
cleanupDoneOne: '已清理 {count} 个过期会话',
cleanupDoneOther: '已清理 {count} 个过期会话',
cleanupNone: '没有需要清理的过期会话',
cleanupFailedBannerOne: '上次自动清理有 {count} 个会话未能删除。',
cleanupFailedBannerOther: '上次自动清理有 {count} 个会话未能删除。',
cleanupErrorBanner: '上次自动清理失败,请稍后在本页重试。',
cleanupFailed: '清理失败:还有 {failed} 个过期会话没有删除。',
cleanupPartial: '已清理 {purged} 个过期会话,{failed} 个没有删除。',
cleanupRetryAt: '将在 {time} 自动重试。',
cleanupRetryNow: '立即重试',
copySuccess: '已复制 Session ID',
copyFailed: '无法复制 Session ID,请手动复制',
revealSuccess: '已在文件管理器中显示原工作区',
revealFailed: '无法打开原工作区',
lastErrorLabel: '上次错误:{message}',
lastErrorTrashCopyMissing: '回收站里的会话副本缺失。',
lastErrorTrashCopyMissingMembers: '回收站里的部分子会话副本缺失。',
lastErrorTrashObjectMissing: '回收站对象目录缺失。',
lastErrorPurgeFailed: '会话日志删除失败。',
lastErrorRestoreInvisible: '恢复后会话存储没有识别到该会话。',
lastErrorMoveUnsettled: '会话已移动,但会话存储仍报告它存在。',
lastErrorSourceConflict: '原会话目录与回收站副本同时存在,两者都已保留。',
lastErrorIndexWriteFailed: '回收站索引写入失败。',
lastErrorIo: '文件操作失败。',
footnote: '回收站目录:{path}',
move: '移入回收站',
moveBlockedLive: '移入回收站(会话已打开)',
moveBlockedActive: '移入回收站(有任务在运行)',
moveBlockedDescendants: '移入回收站(含可见子会话)',
undo: '撤销',
undoFailed: '撤销失败',
trashSuccess: '已将「{title}」移入回收站',
trashSuccessTreeOne: '「{title}」及其 {count} 个子会话已移入回收站',
trashSuccessTreeOther: '「{title}」及其 {count} 个子会话已移入回收站',
blockedLiveToast: '该会话已在本机打开。DSH 目前不会释放已打开的会话,请重启 DSH 后再移入回收站。',
blockedActiveToast: '该会话还有正在运行的任务或子代理,等它停下来后再移入回收站。',
blockedDescendantsToast: '该会话包含可见的子会话,只能使用 DSH 自带的「归档」整棵会话树。',
restoreSuccess: '已恢复「{title}」',
restoreOrphanSuccess: '已恢复为孤儿会话「{title}」',
purgeSuccess: '已永久删除「{title}」,释放 {size}',
purgeSuccessUnknown: '已永久删除「{title}」',
forgetSuccess: '已从回收站列表移除',
errorLive: '这个会话正在使用中,无法移入回收站。',
errorActive: '这个会话还有正在运行的任务,无法移入回收站。',
errorSubagent: '子代理会话不能单独移入回收站。',
errorDescendants: '这个会话还有子会话,请改为归档整棵会话树。',
errorNotMaterialized: '这个会话还没有可移动的日志。',
errorStorage: '当前会话存储后端不支持回收站。',
errorAlreadyTrashed: '这个会话已经在回收站里了。',
errorNotFound: '会话不存在或已被移除。',
errorTrashNotFound: '回收站中未找到该会话。',
errorLocked: '另一个回收站操作正在进行,请稍后再试。',
errorTrashMissing: '回收站中的会话日志已缺失。',
errorRestoreTarget: '原位置已有同名目录,无法恢复。',
errorWorkspaceMissing: '原工作区目录已不存在,暂时无法普通恢复。',
errorWorkspaceUnregistered: '原工作区已从 DSH 中移除,无法直接恢复;请改用「恢复为孤儿会话」。',
errorRestoreVerify: '恢复后会话存储不可见,已回滚。',
errorIndexCorrupt: '回收站索引损坏,已进入保护模式。',
errorIndexOk: '回收站索引可正常读取,无需重建。',
errorForgetNotAllowed: '只有文件缺失的记录可以从索引移除。',
errorRevealUnavailable: '当前环境无法打开文件管理器。',
errorRevealFailed: '无法打开原工作区。',
errorIo: '文件操作失败,请稍后重试。',
}
const en = {
nav: 'Trash',
title: 'Trash',
subtitle: 'Deleted sessions stay here for {days} days and are then permanently deleted.',
refresh: 'Refresh',
retry: 'Retry',
cleanupExpired: 'Delete expired',
cleaning: 'Cleaning…',
statsCountOne: '{count} session',
statsCountOther: '{count} sessions',
statsSize: 'Logs {size}',
logSize: 'Log {size}',
logSizeHint: 'Session logs only; attachments and images are not included.',
storageSummary: 'Session data on this device: {total} — logs {logs} · attachments {attachments} · cache {cache}',
storageSweepable: '{size} sweepable',
storageOrphan: '{size} unreferenced',
storageScanPartial: 'reference scan incomplete',
storageScanUnavailable: 'reference scan unavailable',
storageIndexPartial: 'attachment stats incomplete',
reclaimOpen: 'Clean up unreferenced attachments…',
reclaimTitle: 'Clean up unreferenced attachments?',
reclaimScanning: 'Scanning for unreferenced attachments…',
reclaimSummaryOne: 'Delete {count} attachment object and free {size}.',
reclaimSummaryOther: 'Delete {count} attachment objects and free {size}.',
reclaimBody: 'Only objects older than 24 hours with no session reference are deleted. Shared attachments, session logs, the projection cache, and the search index are not touched. This cannot be undone.',
reclaimHint: 'Close other DSH windows first. If a new session or reference appears during cleanup, the operation stops automatically.',
reclaimConfirmLabel: 'Type “{phrase}” to confirm',
reclaimConfirmPhrase: 'delete attachments',
reclaimConfirm: 'Delete permanently',
reclaimDeleting: 'Deleting…',
reclaimDoneOne: 'Deleted {count} unreferenced attachment and freed {size}.',
reclaimDoneOther: 'Deleted {count} unreferenced attachments and freed {size}.',
reclaimDoneSkipped: 'Deleted {count} unreferenced attachments and freed {size}; skipped {skipped}.',
reclaimStopped: 'A session changed, so cleanup stopped; the remaining objects were not deleted.',
reclaimNothing: 'No unreferenced attachments older than 24 hours.',
reclaimMissing: '{count} trash records have a missing log, so their attachment references cannot be proven. Remove those records before cleanup.',
reclaimForgetMissing: 'Remove missing records and continue',
reclaimBusy: 'The trash is being settled; try again shortly.',
reclaimScanUnavailable: 'This Node runtime has no zstd decoder, so attachment references cannot be scanned safely.',
reclaimScanIncomplete: 'The attachment reference scan is incomplete, so cleanup is blocked. Retry or inspect the DSH logs.',
reclaimStale: 'Sessions changed, so the plan expired. Preview again.',
reclaimExpired: 'The cleanup plan expired. Preview again.',
reclaimRetry: 'Preview again',
searchLabel: 'Search the trash',
searchPlaceholder: 'Search title, Session ID, or original workspace',
searchClear: 'Clear search',
resultsCount: 'Showing {shown} of {total} sessions',
selectRow: 'Select “{title}”',
selectAll: 'Select all selectable sessions on this page',
selectedCount: 'Selected: {count} sessions',
clearSelection: 'Clear selection',
batchRestore: 'Restore selected',
batchRestoring: 'Restoring…',
batchRestoreDoneOne: 'Restored {count} session',
batchRestoreDoneOther: 'Restored {count} sessions',
batchRestorePartial: 'Restored {restored}; {failed} failed',
sortLabel: 'Sort by',
sortTrashed: 'Newest trashed first',
sortTitle: 'Title',
sortSize: 'Largest first',
sortExpires: 'Expiring soonest first',
expandMembers: 'Show sub-sessions',
collapseMembers: 'Hide sub-sessions',
memberParent: 'Parent',
memberSubagent: 'Sub-session',
filterLabel: 'Filter the trash',
filterAll: 'All',
filterWorkspaceExists: 'Restorable to workspace',
filterWorkspaceMissing: 'Orphan restore only',
filterExpiring: 'Expiring soon',
filterResults: '{count} sessions shown',
noResultsTitle: 'No matching sessions',
noResultsBody: 'Try a different keyword, or clear the search and filters.',
clearFilters: 'Clear filters',
paginationLabel: 'Trash pagination',
previousPage: 'Previous page',
nextPage: 'Next page',
pageInfo: 'Page {page} of {total}',
pageAnnouncement: 'Page {page} of {total}',
nextSweep: 'Next automatic cleanup: {date}',
nextSweepUnknown: 'Next automatic cleanup: checked when this page opens',
autoCleanupOff: 'Automatic cleanup is off',
autoCleanupBanner: 'Automatic cleanup is off. Expired sessions are kept until you delete them.',
emptyTitle: 'Trash is empty',
emptyBody: 'Right-click a session in the sidebar and choose “Move to trash”.',
loading: 'Loading…',
errorNetwork: 'Could not reach the trash service.',
errorTimeout: 'The request timed out. Try again.',
errorUnauthorized: 'Your connection expired. Reload the page.',
errorForbidden: 'You do not have access to the trash.',
errorGeneric: 'Could not load the trash.',
corruptBanner: 'The trash index is damaged, so protection mode is on. No session is changed automatically.',
recoveredBanner: 'The trash index was recovered from its backup.',
unindexedBanner: 'The trash directory holds {count} unindexed objects. The plugin will not delete them.',
orphansClean: 'Clean empty leftovers',
orphansTitle: 'Remove empty unindexed objects?',
orphansBody: 'Only leftover directories without session logs are removed; unindexed objects that may contain logs are kept.',
orphansConfirm: 'Clean empty objects',
orphansDoneOne: 'Removed {count} empty unindexed object',
orphansDoneOther: 'Removed {count} empty unindexed objects',
orphansNone: 'No empty leftovers to clean',
rebuild: 'Try rebuilding the index',
rebuilding: 'Rebuilding…',
rebuildDone: 'Index rebuilt with {count} entries',
rebuildDoneUnindexed: 'Index rebuilt with {count} entries; {unindexed} unindexed objects were kept',
listLabel: 'Deleted sessions',
noWorkspace: 'Ungrouped',
workspaceLabel: 'Original workspace:',
unknownWorkspace: 'Unknown workspace',
trashedAtLabel: 'Trashed',
notScheduled: 'Not scheduled for cleanup',
expiresOn: 'Auto-deletes on {date}',
badgeMissing: 'Log missing',
badgeWorkspaceMissing: 'Workspace missing',
badgeWorkspaceRemoved: 'Workspace removed',
badgeMigration: 'Migration required',
badgeExpiring: 'Expiring soon',
badgeExpired: 'Expired',
badgeSubagentsOne: '{count} sub-session',
badgeSubagentsOther: '{count} sub-sessions',
stateTrashing: 'Moving…',
stateRestoring: 'Restoring…',
statePurging: 'Deleting…',
actionRestore: 'Restore',
actionRestoreFor: 'Restore “{title}”',
actionMoreFor: 'More actions for “{title}”',
actionRestoreOrphan: 'Restore as orphan',
actionReveal: 'Show in file manager',
actionRevealDisabled: 'The original workspace no longer exists',
actionCopyId: 'Copy Session ID',
actionForget: 'Remove from index',
actionPurge: 'Delete permanently',
dialogCancel: 'Cancel',
orphanTitle: 'Original workspace is missing',
orphanBody: '“{path}” no longer exists. An orphan restore puts the session back under “Ungrouped” and never recreates the directory.',
orphanRemovedTitle: 'The original workspace was removed',
orphanRemovedBody:
'“{path}” is still on disk but no longer appears in the DSH workspace list, so the session cannot rejoin it. An orphan restore returns the session under “Ungrouped” and leaves the directory untouched.',
orphanConfirm: 'Restore as orphan',
purgeTitle: 'Permanently delete the session log for “{title}”?',
purgeBody: 'This cannot be undone. The session log and its projection-cache record are deleted; attachments and images are kept, and the search index drops the session on its next search.',
purgeConfirm: 'Delete permanently',
purgeAll: 'Delete all permanently',
purgingAll: 'Deleting…',
purgeAllTitle: 'Permanently delete all {count} sessions in the trash?',
purgeAllBody: 'This cannot be undone. The session logs and their projection-cache records are deleted; attachments and images are kept, and the search index drops these sessions on its next search.',
purgeAllConfirm: 'Delete all permanently',
purgeAllDoneOne: 'Permanently deleted {count} session, freeing {size}',
purgeAllDoneOther: 'Permanently deleted {count} sessions, freeing {size}',
purgeAllDonePlainOne: 'Permanently deleted {count} session',
purgeAllDonePlainOther: 'Permanently deleted {count} sessions',
purgeAllNone: 'No sessions to delete',
purgeAllPartial: 'Bulk delete finished: {removed} removed, {failed} failed, {size} freed.',
purgeAllPartialPlain: 'Bulk delete finished: {removed} removed, {failed} failed.',
forgetTitle: 'Remove this missing record from the trash list?',
forgetBody: 'No file is deleted; only this index record is removed.',
forgetConfirm: 'Remove from index',
cleanupDoneOne: 'Deleted {count} expired session',
cleanupDoneOther: 'Deleted {count} expired sessions',
cleanupNone: 'No expired sessions to delete',
cleanupFailedBannerOne: 'The last automatic cleanup could not delete {count} expired session.',
cleanupFailedBannerOther: 'The last automatic cleanup could not delete {count} expired sessions.',
cleanupErrorBanner: 'The last automatic cleanup failed. Retry from this page later.',
cleanupFailed: 'Cleanup could not delete {failed} of the expired sessions.',
cleanupPartial: 'Cleanup deleted {purged}; {failed} could not be deleted.',
cleanupRetryAt: 'Next retry: {time}.',
cleanupRetryNow: 'Retry now',
copySuccess: 'Session ID copied',
copyFailed: 'Could not copy the Session ID. Copy it manually.',
revealSuccess: 'Revealed the original workspace in the file manager',
revealFailed: 'Could not open the original workspace',
lastErrorLabel: 'Last error: {message}',
lastErrorTrashCopyMissing: 'The stored copy of this session is missing from the trash.',
lastErrorTrashCopyMissingMembers: 'Some sub-session copies are missing from the trash.',
lastErrorTrashObjectMissing: 'The trash object directory is missing.',
lastErrorPurgeFailed: 'The session log could not be deleted.',
lastErrorRestoreInvisible: 'Session storage did not report the restored session.',
lastErrorMoveUnsettled: 'The session was moved, but session storage still reports it.',
lastErrorSourceConflict: 'The original session directory and the trash copy both exist; both were kept.',
lastErrorIndexWriteFailed: 'The trash index could not be written.',
lastErrorIo: 'A file operation failed.',
footnote: 'Trash directory: {path}',
move: 'Move to trash',
moveBlockedLive: 'Move to trash (session is open)',
moveBlockedActive: 'Move to trash (work is running)',
moveBlockedDescendants: 'Move to trash (has visible sub-sessions)',
undo: 'Undo',
undoFailed: 'Could not undo',
trashSuccess: 'Moved “{title}” to the trash',
trashSuccessTreeOne: '“{title}” and its single sub-session were moved to the trash',
trashSuccessTreeOther: '“{title}” and its {count} sub-sessions were moved to the trash',
blockedLiveToast: 'This session is open in DSH. DSH does not release opened sessions yet; restart DSH, then move it to the trash.',
blockedActiveToast: 'This session still has running work; wait for it to stop, then move it to the trash.',
blockedDescendantsToast: 'This session has visible child sessions; use the built-in Archive action for the whole tree instead.',
restoreSuccess: 'Restored “{title}”',
restoreOrphanSuccess: 'Restored “{title}” as an orphan session',
purgeSuccess: 'Permanently deleted “{title}” and freed {size}',
purgeSuccessUnknown: 'Permanently deleted “{title}”',
forgetSuccess: 'Removed from the trash list',
errorLive: 'This session is in use and cannot be moved to the trash.',
errorActive: 'This session still has running work.',
errorSubagent: 'A subagent session cannot be trashed on its own.',
errorDescendants: 'This session still has child sessions; archive the whole tree instead.',
errorNotMaterialized: 'This session has no stored log yet.',
errorStorage: 'The current session storage backend is not supported.',
errorAlreadyTrashed: 'This session is already in the trash.',
errorNotFound: 'This session no longer exists.',
errorTrashNotFound: 'That session is no longer in the trash.',
errorLocked: 'Another trash operation is in progress. Try again in a moment.',
errorTrashMissing: 'The stored session log is missing from the trash.',
errorRestoreTarget: 'A directory already exists at the original location.',
errorWorkspaceMissing: 'The original workspace directory no longer exists, so a normal restore is not possible.',
errorWorkspaceUnregistered:
'The original workspace is no longer registered with DSH, so a direct restore is not possible. Use “Restore as orphan” instead.',
errorRestoreVerify: 'Session storage could not see the restored session; the move was rolled back.',
errorIndexCorrupt: 'The trash index is damaged, so protection mode is on.',
errorIndexOk: 'The trash index is readable and does not need a rebuild.',
errorForgetNotAllowed: 'Only records whose log is missing can be removed from the index.',
errorRevealUnavailable: 'This environment cannot open a file manager.',
errorRevealFailed: 'Could not open the original workspace.',
errorIo: 'A file operation failed. Try again.',
}
/**
* Replace `{name}` placeholders without relying on locale interpolation.
* @param {string} template localized text.
* @param {Record<string, unknown>} values replacement values.
* @returns {string} formatted text.
*/
function format(template, values) {
if (typeof template !== 'string') return ''
return template.replace(/\{(\w+)\}/g, (match, key) =>
values !== undefined && values[key] !== undefined ? String(values[key]) : match,
)
}
/**
* Pick the grammatical singular/plural locale form for a count.
*
* @param {(key: string) => string} t bound translator.
* @param {string} key base locale key (without the One/Other suffix).
* @param {number} count item count.
* @param {Record<string, unknown>} [values] extra placeholders.
* @returns {string} the formatted text.
*/
function countText(t, key, count, values = {}) {
const template = t(`${key}${count === 1 ? 'One' : 'Other'}`)
return format(template, { ...values, count })
}
/**
* Compare two trash entries for the selected sort order.
*
* @param {any} left first entry.
* @param {any} right second entry.
* @param {string} sortKey active sort identifier.
* @param {string | undefined} locale active locale.
* @returns {number} comparator result.
*/
function compareEntries(left, right, sortKey, locale) {
const titleOf = (entry) => (typeof entry.title === 'string' && entry.title !== '' ? entry.title : entry.sessionId)
if (sortKey === 'title') return String(titleOf(left)).localeCompare(String(titleOf(right)), locale)
if (sortKey === 'size') return (Number(right.sizeBytes) || 0) - (Number(left.sizeBytes) || 0)
if (sortKey === 'expires') {
const leftAt = typeof left.expiresAt === 'number' ? left.expiresAt : Number.POSITIVE_INFINITY
const rightAt = typeof right.expiresAt === 'number' ? right.expiresAt : Number.POSITIVE_INFINITY
return leftAt - rightAt
}
return (right.trashedAt ?? 0) - (left.trashedAt ?? 0)
}
/**
* Read the readable workspace name of a trashed entry. Older Host payloads
* omit `originalWorkspaceTitle`, so the basename of `originalCwd` is the
* fallback.
*
* @param {object} entry wire entry.
* @returns {string} the workspace name, or an empty string when unknown.
*/
function workspaceName(entry) {
const title = typeof entry.originalWorkspaceTitle === 'string' ? entry.originalWorkspaceTitle.trim() : ''
if (title !== '') return title
const cwd = typeof entry.originalCwd === 'string' ? entry.originalCwd.replace(/[\\/]+$/, '') : ''
const separator = Math.max(cwd.lastIndexOf('/'), cwd.lastIndexOf('\\'))
return cwd.slice(separator + 1)
}
/**
* @param {number | null | undefined} bytes raw byte count.
* @returns {string} a compact human-readable size, or an em dash when unknown.
*/
function formatBytes(bytes) {
if (typeof bytes !== 'number' || !Number.isFinite(bytes)) return '—'
if (bytes <= 0) return '0 B'
const units = ['B', 'KB', 'MB', 'GB', 'TB']
let value = bytes
let unit = 0
while (value >= 1024 && unit < units.length - 1) {
value /= 1024
unit += 1
}
const rounded = unit === 0 ? Math.round(value) : Math.round(value * 10) / 10
return `${rounded} ${units[unit]}`
}
/**
* @param {object | null | undefined} locale locale service snapshot source.
* @returns {string | undefined} the active BCP 47 locale tag.
*/
function activeLocale(locale) {
try {
const snapshot = typeof locale?.getSnapshot === 'function' ? locale.getSnapshot() : undefined
return typeof snapshot?.active === 'string' ? snapshot.active : undefined
} catch {
return undefined
}
}
/**
* @param {number | null | undefined} timestamp epoch milliseconds.
* @param {string | undefined} locale active locale tag.
* @param {boolean} [withTime] include the time of day.
* @returns {string} a locale-aware date, or an em dash for a missing value.
*/
function formatDate(timestamp, locale, withTime = false) {
if (typeof timestamp !== 'number' || !Number.isFinite(timestamp) || timestamp <= 0) return '—'
try {
return new Intl.DateTimeFormat(
locale,
withTime ? { dateStyle: 'medium', timeStyle: 'short' } : { dateStyle: 'medium' },
).format(new Date(timestamp))
} catch {
return new Date(timestamp).toISOString().slice(0, 10)
}
}
/**
* @param {number} days day offset from now.
* @param {string | undefined} locale active locale tag.
* @returns {string} a relative day phrase.
*/
function relativeDays(days, locale) {
try {
return new Intl.RelativeTimeFormat(locale, { numeric: 'auto' }).format(days, 'day')
} catch {
return `${days}d`
}
}
/**
* @param {object} entry wire entry.
* @param {string | undefined} locale active locale tag.
* @param {number} now current timestamp.
* @returns {{ days: number | null, text: string }} remaining retention facts.
*/
function remaining(entry, locale, now) {
if (entry.state !== 'trashed' || typeof entry.expiresAt !== 'number') {
return { days: null, text: '' }
}
const days = Math.ceil((entry.expiresAt - now) / DAY_MS)
return { days, text: days <= 0 ? '' : relativeDays(days, locale) }
}
/**
* Call one endpoint of this plugin's Host API.
*
* The path stays a literal inside the `fetch` call rather than being built
* from a constant: a capability scan can only tell that a request stays on
* this origin when the argument is a path-locked literal, and it counts a
* variable as outbound. Keep the literal equal to `API_PREFIX` in
* `lib/http.js`.
*
* @param {string} pathname endpoint name below the API prefix.
* @param {{ method?: string, body?: unknown, signal?: AbortSignal }} [options] request options.
* @returns {Promise<{ status: number, ok: boolean, payload: any }>} the decoded response.
*/
async function requestJson(pathname, options = {}) {
const { method = 'GET', body, signal } = options
const headers = { [CSRF_HEADER]: '1' }
if (body !== undefined) headers['Content-Type'] = 'application/json'
const response = await fetch(`/plugins/dsh-session-trash/api/${pathname}`, {
method,
credentials: 'same-origin',
cache: 'no-store',
headers,
body: body === undefined ? undefined : JSON.stringify(body),
signal,
})
let payload = null
try {
payload = await response.json()
} catch {
payload = null
}
return { status: response.status, ok: response.ok, payload }
}
/**
* @param {number} status HTTP status.
* @param {{ error?: { code?: string } } | null} payload decoded error body.
* @param {(key: string) => string} t bound translator.
* @returns {string} localized failure text.
*/
function describeFailure(status, payload, t) {
if (status === 401) return t('errorUnauthorized')
if (status === 403) return t('errorForbidden')
const code = payload !== null && payload !== undefined && payload.error !== undefined ? payload.error.code : undefined
if (status === 500 && code === 'INDEX_CORRUPT') return t('corruptBanner')
return code === undefined ? t('errorGeneric') : `${t('errorGeneric')} (${code})`
}
/** Stable Host error codes mapped to owner-facing action messages. */
const ACTION_ERROR_KEYS = {
SESSION_NOT_FOUND: 'errorNotFound',
SESSION_LIVE: 'errorLive',
SESSION_ACTIVE: 'errorActive',
SESSION_SUBAGENT: 'errorSubagent',
SESSION_HAS_DESCENDANTS: 'errorDescendants',
SESSION_NOT_MATERIALIZED: 'errorNotMaterialized',
STORAGE_UNSUPPORTED: 'errorStorage',
ALREADY_TRASHED: 'errorAlreadyTrashed',
LOCKED: 'errorLocked',
TRASH_DIR_MISSING: 'errorTrashMissing',
TRASH_ENTRY_NOT_FOUND: 'errorTrashNotFound',
TRASH_STATE_INVALID: 'errorTrashNotFound',
RESTORE_TARGET_EXISTS: 'errorRestoreTarget',
WORKSPACE_MISSING: 'errorWorkspaceMissing',
WORKSPACE_UNREGISTERED: 'errorWorkspaceUnregistered',
RESTORE_VERIFY_FAILED: 'errorRestoreVerify',
MOVE_VERIFY_FAILED: 'errorRestoreVerify',
MOVE_CONFLICT: 'errorIo',
INDEX_CORRUPT: 'errorIndexCorrupt',
INDEX_NOT_CORRUPT: 'errorIndexOk',
INDEX_WRITE_FAILED: 'errorIo',
FORGET_NOT_ALLOWED: 'errorForgetNotAllowed',
REVEAL_UNAVAILABLE: 'errorRevealUnavailable',
REVEAL_FAILED: 'errorRevealFailed',
UNSAFE_SESSION_DIR: 'errorIo',
UNSAFE_RESTORE_PATH: 'errorIo',
IO_ERROR: 'errorIo',
}
/**
* Translate one failed mutation into a concise localized message.
*
* @param {number} status HTTP status.
* @param {{ error?: { code?: string } } | null} payload decoded error body.
* @param {(key: string) => string} t bound translator.
* @returns {string} localized failure text.
*/
function describeActionFailure(status, payload, t) {
if (status === 401) return t('errorUnauthorized')
if (status === 403) return t('errorForbidden')
const code = payload !== null && payload !== undefined && payload.error !== undefined ? payload.error.code : undefined
const key = code === undefined ? undefined : ACTION_ERROR_KEYS[code]
return key === undefined ? t('errorIo') : t(key)
}
/**
* @param {string} sessionId session whose eligibility to ask for.
* @param {AbortSignal} [outerSignal] cancellation from the menu occurrence.
* @returns {Promise<{ eligible: boolean, code?: string, message?: string, details?: unknown } | null>} the verdict, or null when unknown.
*/
async function preflight(sessionId, outerSignal) {
const controller = new AbortController()
const timer = setTimeout(() => controller.abort(), PREFLIGHT_TIMEOUT_MS)
const forward = () => controller.abort()
if (outerSignal !== undefined) outerSignal.addEventListener('abort', forward, { once: true })
try {
const { status, ok, payload } = await requestJson('preflight', {
method: 'POST',
body: { sessionId },
signal: controller.signal,
})
if (!ok || payload === null || typeof payload.eligible !== 'boolean') {
if (status === 401 || status === 403) return { eligible: false, code: 'FORBIDDEN' }
return null
}
return payload
} catch {
return null
} finally {
clearTimeout(timer)
if (outerSignal !== undefined) outerSignal.removeEventListener('abort', forward)
}
}
/**
* @param {string} text text to copy.
* @returns {Promise<boolean>} whether the clipboard accepted the text.
*/
async function copyText(text) {
try {
if (navigator.clipboard !== undefined && typeof navigator.clipboard.writeText === 'function') {
await navigator.clipboard.writeText(text)
return true
}
} catch {
// Fall back to a hidden textarea below.
}
try {
const area = document.createElement('textarea')
area.value = text
area.setAttribute('readonly', '')
area.style.position = 'fixed'
area.style.top = '-1000px'
area.style.opacity = '0'
document.body.appendChild(area)
area.select()
const copied = document.execCommand('copy')
area.remove()
return copied
} catch {
return false
}
}
/**
* Trash artwork copied verbatim from the DeepSeek Harness product icon set
* (`trash-outline`, regular weight, MIT © 2026 DeepSeek), so the menu entry
* matches the shipped “Delete workspace” glyph instead of a look-alike.
*/
const TRASH_PATHS = [
'M1.28149 3.88831H14.7187',
'M5.41602 3.88833V2.47962C5.41602 2.29282 5.52492 2.11366 5.71876 1.98157C5.9126 1.84948 6.17551 1.77527 6.44964 1.77527H9.55053C9.82466 1.77527 10.0876 1.84948 10.2814 1.98157C10.4753 2.11366 10.5842 2.29282 10.5842 2.47962V3.88833',
'M2.57349 3.88831L3.19366 13.2943C3.21937 13.5502 3.33952 13.7872 3.53065 13.9593C3.72178 14.1313 3.97016 14.2259 4.22729 14.2246H11.7728C12.0299 14.2259 12.2783 14.1313 12.4694 13.9593C12.6605 13.7872 12.7807 13.5502 12.8064 13.2943L13.4266 3.88831',
'M6.44946 6.98926V11.1238',
'M9.55054 6.98926V11.1238',
]
/**
* @param {{ size?: number, active?: boolean }} props icon presentation.
* @returns {import('react').ReactElement} the trash glyph.
*/
function TrashGlyph(props) {
const size = typeof props?.size === 'number' ? props.size : 16
return h(
'svg',
{
viewBox: '0 0 16 16',
width: size,
height: size,
fill: 'none',
stroke: 'currentColor',
strokeWidth: 1,
'aria-hidden': true,
focusable: false,
style: { display: 'block', flex: 'none' },
},
TRASH_PATHS.map((d, index) => h('path', { key: index, d })),
)
}
/**
* @param {{ size?: number }} props icon presentation.
* @returns {import('react').ReactElement} a vertical ellipsis glyph.
*/
function MoreGlyph(props) {
const size = typeof props?.size === 'number' ? props.size : 16
return h(
'svg',
{
viewBox: '0 0 16 16',
width: size,
height: size,
fill: 'currentColor',
'aria-hidden': true,
focusable: false,
style: { display: 'block', flex: 'none' },
},
[3, 8, 13].map((cy) => h('circle', { key: cy, cx: 8, cy, r: 1.15 })),
)
}
/**
* @param {{ size?: number }} props icon presentation.
* @returns {import('react').ReactElement} a magnifier glyph.
*/
function SearchGlyph(props) {
const size = typeof props?.size === 'number' ? props.size : 16
return h(
'svg',
{
viewBox: '0 0 16 16',
width: size,
height: size,
fill: 'none',
stroke: 'currentColor',
strokeWidth: 1.2,
strokeLinecap: 'round',
'aria-hidden': true,
focusable: false,
style: { display: 'block', flex: 'none' },
},
[
h('circle', { key: 'circle', cx: 7, cy: 7, r: 4.25 }),
h('path', { key: 'handle', d: 'M10.25 10.25L13.5 13.5' }),
],
)
}
/**
* @param {{ size?: number }} props icon presentation.
* @returns {import('react').ReactElement} a diagonal cross glyph.
*/
function CloseGlyph(props) {
const size = typeof props?.size === 'number' ? props.size : 16
return h(
'svg',
{
viewBox: '0 0 16 16',
width: size,
height: size,
fill: 'none',
stroke: 'currentColor',
strokeWidth: 1.4,
strokeLinecap: 'round',
'aria-hidden': true,
focusable: false,
style: { display: 'block', flex: 'none' },
},
[h('path', { key: 'a', d: 'M4.5 4.5L11.5 11.5' }), h('path', { key: 'b', d: 'M11.5 4.5L4.5 11.5' })],
)
}
const STYLES = `
.dsh-trash { display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: 760px; margin: 0 auto; padding: 8px 0 48px; color: var(--dsw-alias-label-primary); }
.dsh-trash__header { display: flex; flex-direction: column; gap: 6px; }
.dsh-trash__title { margin: 0; font-size: 20px; font-weight: 600; line-height: 1.3; }
.dsh-trash__subtitle { margin: 0; font-size: 13px; line-height: 1.5; color: var(--dsw-alias-label-secondary); }
.dsh-trash__toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 12px; }
.dsh-trash__storage { font-size: 12.5px; line-height: 1.5; color: var(--dsw-alias-label-secondary); opacity: 0.9; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.dsh-trash__linkButton { border: 0; padding: 0; background: none; color: var(--dsw-alias-brand-primary, var(--dsw-alias-label-primary)); font: inherit; font-size: 12.5px; cursor: pointer; text-decoration: underline; }
.dsh-trash__dialogHint { margin: 6px 0 0; font-size: 12px; color: var(--dsw-alias-label-tertiary); }
.dsh-trash__reclaimInput { box-sizing: border-box; width: 100%; height: 34px; margin-top: 10px; padding: 0 10px; border: 0.5px solid var(--dsw-alias-border-l4); border-radius: var(--dsw-radius-md); background: var(--dsw-alias-bg-layer-3); color: var(--dsw-alias-label-primary); font: inherit; font-size: 13px; outline: none; }
.dsh-trash__reclaimMissing { margin: 8px 0 0; padding-left: 18px; max-height: 140px; overflow: auto; font-size: 12.5px; }
.dsh-trash__stats { font-size: 13px; color: var(--dsw-alias-label-secondary); display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; }
.dsh-trash__dot { opacity: 0.5; }
.dsh-trash__toolbarActions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.dsh-trash__controls { display: flex; flex-direction: column; gap: 10px; }