dsh-broom 0.1.0 → 0.1.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/client.js +139 -139
- package/cordis.patch.yml +1 -1
- package/index.js +2 -2
- package/lib/clean.mjs +1 -1
- package/lib/errors.mjs +1 -1
- package/lib/guard.mjs +1 -1
- package/lib/home.mjs +1 -1
- package/lib/routes.mjs +7 -7
- package/lib/store.mjs +1 -1
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* dsh-
|
|
2
|
+
* dsh-broom 浏览器半边:设置 → 归档会话。
|
|
3
3
|
* 查看会话和 DSH 官方归档,支持清理与还原。
|
|
4
4
|
*/
|
|
5
5
|
window.__ModuleLoader__.load({
|
|
@@ -10,7 +10,7 @@ window.__ModuleLoader__.load({
|
|
|
10
10
|
const { useState, useEffect, useLayoutEffect, useRef, useMemo, useCallback, useSyncExternalStore } = React;
|
|
11
11
|
const h = React.createElement;
|
|
12
12
|
|
|
13
|
-
const NS = 'dsh-
|
|
13
|
+
const NS = 'dsh-broom';
|
|
14
14
|
|
|
15
15
|
const LOCALES = {
|
|
16
16
|
en: {
|
|
@@ -415,7 +415,7 @@ window.__ModuleLoader__.load({
|
|
|
415
415
|
reference_check_failed: 'error.referenceCheck' };
|
|
416
416
|
function errorText(error, t, workspaceT = t) {
|
|
417
417
|
const message = String(error?.message ?? error ?? '');
|
|
418
|
-
const embedded = /dsh-
|
|
418
|
+
const embedded = /dsh-broom:([a-z_]+)/.exec(message);
|
|
419
419
|
const code = embedded?.[1] || error?.code;
|
|
420
420
|
const key = ERROR_KEYS[code] || (Object.hasOwn(ERROR_LOCALES.en, `error.${code}`) ? `error.${code}` : null);
|
|
421
421
|
const reason = code === 'already_archived' ? workspaceT('row.archived') : key ? t(key) : message;
|
|
@@ -510,21 +510,21 @@ window.__ModuleLoader__.load({
|
|
|
510
510
|
function HoverPlacement({ anchorRef }) {
|
|
511
511
|
const marker = useRef(null);
|
|
512
512
|
useLayoutEffect(() => {
|
|
513
|
-
const card = marker.current?.closest('.dsh-
|
|
513
|
+
const card = marker.current?.closest('.dsh-broom-hover-content')?.parentElement;
|
|
514
514
|
const portal = card?.parentElement;
|
|
515
515
|
const anchor = anchorRef.current;
|
|
516
516
|
const panel = anchor?.closest('[data-shortcut-modal="settings"]');
|
|
517
517
|
if (!card || !portal || !panel) return;
|
|
518
518
|
// The official component temporarily replaces card content after copy.
|
|
519
519
|
// Keep placement on its portal, which survives the feedback state.
|
|
520
|
-
portal.dataset.
|
|
520
|
+
portal.dataset.dshBroomPositioned = '';
|
|
521
521
|
const place = () => {
|
|
522
522
|
const width = card.getBoundingClientRect().width;
|
|
523
523
|
const anchorBounds = anchor.getBoundingClientRect();
|
|
524
524
|
const right = anchorBounds.right + 24 + 1;
|
|
525
525
|
const left = anchorBounds.left - width - 1;
|
|
526
526
|
const x = right + width <= window.innerWidth - 8 ? right : Math.max(8, left);
|
|
527
|
-
portal.style.setProperty('--dsh-
|
|
527
|
+
portal.style.setProperty('--dsh-broom-card-left', `${x}px`);
|
|
528
528
|
};
|
|
529
529
|
place();
|
|
530
530
|
window.addEventListener('resize', place);
|
|
@@ -540,11 +540,11 @@ window.__ModuleLoader__.load({
|
|
|
540
540
|
return next(a) - next(b);
|
|
541
541
|
});
|
|
542
542
|
const visibleTasks = [...active.slice(0, 2), ...tasks.filter((task) => task.status !== 'active')];
|
|
543
|
-
return h('div', { className: 'dsh-
|
|
544
|
-
h(HoverPlacement, { anchorRef }), h('div', { className: 'dsh-
|
|
545
|
-
path ? h('div', { className: 'dsh-
|
|
546
|
-
time ? h('div', { className: 'dsh-
|
|
547
|
-
...visibleTasks.map((task, index) => h('button', { key: task.id || index, type: 'button', className: 'dsh-
|
|
543
|
+
return h('div', { className: 'dsh-broom-hover-content' },
|
|
544
|
+
h(HoverPlacement, { anchorRef }), h('div', { className: 'dsh-broom-hover-title' }, title),
|
|
545
|
+
path ? h('div', { className: 'dsh-broom-hover-path' }, path) : null,
|
|
546
|
+
time ? h('div', { className: 'dsh-broom-hover-time' }, time) : null,
|
|
547
|
+
...visibleTasks.map((task, index) => h('button', { key: task.id || index, type: 'button', className: 'dsh-broom-hover-status dsh-broom-hover-archived dsh-broom-hover-task-button',
|
|
548
548
|
disabled: !task.id, onClick: (event) => { event.stopPropagation(); return onOpenTask?.(task.id); },
|
|
549
549
|
onKeyDown: (event) => { event.stopPropagation(); } },
|
|
550
550
|
task.status === 'active' && task.officialVisible && officialSchedule && scheduleSnapshot?.settled
|
|
@@ -552,12 +552,12 @@ window.__ModuleLoader__.load({
|
|
|
552
552
|
useCatalog: (selector) => selector({ ...scheduleSnapshot, records: [task.record] }) })
|
|
553
553
|
: h(React.Fragment, null, officialIcon('clock-outline', 14), h('span', null, task.title || task.id),
|
|
554
554
|
task.showStatus || task.status === 'paused' || task.status === 'ended' ? h('span', null, scheduleT?.(`status.${task.status}`)) : null))),
|
|
555
|
-
active.length > 2 ? h('div', { className: 'dsh-
|
|
556
|
-
...(statuses ?? (status ? [status] : [])).map((entry) => h('div', { key: entry.key, className: 'dsh-
|
|
555
|
+
active.length > 2 ? h('div', { className: 'dsh-broom-hover-time' }, catalogT?.('hover.more', { count: active.length - 2 })) : null,
|
|
556
|
+
...(statuses ?? (status ? [status] : [])).map((entry) => h('div', { key: entry.key, className: 'dsh-broom-hover-status' },
|
|
557
557
|
h(StateDot, { state: entry.state }), h('span', null, t(entry.key, entry.params)))),
|
|
558
|
-
archived ? h('div', { className: 'dsh-
|
|
558
|
+
archived ? h('div', { className: 'dsh-broom-hover-status dsh-broom-hover-archived' },
|
|
559
559
|
officialIcon('archive-outline', 14), h('span', null, t('row.archived'))) : null,
|
|
560
|
-
reason ? h('div', { className: 'dsh-
|
|
560
|
+
reason ? h('div', { className: 'dsh-broom-hover-status' },
|
|
561
561
|
officialIcon('shield-outline', 14), h('span', null, reason)) : null);
|
|
562
562
|
}
|
|
563
563
|
|
|
@@ -572,7 +572,7 @@ window.__ModuleLoader__.load({
|
|
|
572
572
|
const titleFrames = new WeakMap();
|
|
573
573
|
function titleEnter(event) {
|
|
574
574
|
if (event.pointerType === 'touch') return;
|
|
575
|
-
const element = event.currentTarget.querySelector('.dsh-
|
|
575
|
+
const element = event.currentTarget.querySelector('.dsh-broom-title');
|
|
576
576
|
if (!element || titleFrames.has(element)) return;
|
|
577
577
|
const range = element.scrollWidth - element.clientWidth;
|
|
578
578
|
if (range <= 8) return;
|
|
@@ -594,7 +594,7 @@ window.__ModuleLoader__.load({
|
|
|
594
594
|
titleFrames.set(element, requestAnimationFrame(step));
|
|
595
595
|
}
|
|
596
596
|
function titleLeave(event) {
|
|
597
|
-
const element = event.currentTarget.querySelector('.dsh-
|
|
597
|
+
const element = event.currentTarget.querySelector('.dsh-broom-title');
|
|
598
598
|
if (!element) return;
|
|
599
599
|
if (titleFrames.has(element)) cancelAnimationFrame(titleFrames.get(element));
|
|
600
600
|
titleFrames.delete(element);
|
|
@@ -750,7 +750,7 @@ window.__ModuleLoader__.load({
|
|
|
750
750
|
const refresh = useCallback(async () => {
|
|
751
751
|
setBusy(true);
|
|
752
752
|
try {
|
|
753
|
-
const response = await fetch('api/dsh-
|
|
753
|
+
const response = await fetch('api/dsh-broom.overview');
|
|
754
754
|
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
755
755
|
const raw = await response.json();
|
|
756
756
|
if (raw?.error) throw new Error(raw.error);
|
|
@@ -763,7 +763,7 @@ window.__ModuleLoader__.load({
|
|
|
763
763
|
const data = raw;
|
|
764
764
|
// DSH 的 session/list 含官方 blank 标志;标题不等于空白状态。
|
|
765
765
|
try {
|
|
766
|
-
const rpcId = globalThis.crypto?.randomUUID?.() ?? `dsh-
|
|
766
|
+
const rpcId = globalThis.crypto?.randomUUID?.() ?? `dsh-broom-${Date.now()}-${Math.random()}`;
|
|
767
767
|
const summaryResponse = await fetch('api/session/list', {
|
|
768
768
|
method: 'POST', headers: { 'content-type': 'application/json' },
|
|
769
769
|
body: JSON.stringify({ type: 'client-request', rpcId, method: 'session/list', payload: { args: { _request: {} } } }),
|
|
@@ -773,7 +773,7 @@ window.__ModuleLoader__.load({
|
|
|
773
773
|
Object.assign(data, mergeSessionSummaries(data, summary, rpcId));
|
|
774
774
|
} catch (error) {
|
|
775
775
|
// 无法取得标记时仍展示清单;不要根据标题猜测空白状态。
|
|
776
|
-
console.warn('dsh-
|
|
776
|
+
console.warn('dsh-broom: session status unavailable', error);
|
|
777
777
|
}
|
|
778
778
|
setOverview(data);
|
|
779
779
|
setLoadError(false);
|
|
@@ -791,14 +791,14 @@ window.__ModuleLoader__.load({
|
|
|
791
791
|
const syncSessionList = useCallback(async () => {
|
|
792
792
|
if (typeof sessionsService?.refresh !== 'function') return;
|
|
793
793
|
try { await sessionsService.refresh(); }
|
|
794
|
-
catch (error) { console.warn('dsh-
|
|
794
|
+
catch (error) { console.warn('dsh-broom: session list refresh failed', error); }
|
|
795
795
|
}, [sessionsService]);
|
|
796
796
|
useEffect(() => { void syncSessionList(); }, [syncSessionList]);
|
|
797
797
|
|
|
798
798
|
const post = useCallback(async (action, body) => {
|
|
799
799
|
setBusy(true);
|
|
800
800
|
try {
|
|
801
|
-
const response = await fetch(`api/dsh-
|
|
801
|
+
const response = await fetch(`api/dsh-broom.${action}`, {
|
|
802
802
|
method: 'POST',
|
|
803
803
|
headers: { 'content-type': 'application/json' },
|
|
804
804
|
body: JSON.stringify(body ?? {}),
|
|
@@ -976,8 +976,8 @@ window.__ModuleLoader__.load({
|
|
|
976
976
|
setDialog({ kind: 'taskDetail', task: result.task });
|
|
977
977
|
} catch (error) {
|
|
978
978
|
const message = String(error?.message ?? error);
|
|
979
|
-
showNotice(message.includes('dsh-
|
|
980
|
-
: message.includes('dsh-
|
|
979
|
+
showNotice(message.includes('dsh-broom:task_not_found') ? scheduleT('detail.missing')
|
|
980
|
+
: message.includes('dsh-broom:task_unavailable') ? scheduleT('list.error') : errorText(error, t), true);
|
|
981
981
|
}
|
|
982
982
|
},
|
|
983
983
|
onSelect: (key, on) => setChecked((prev) => {
|
|
@@ -1033,36 +1033,36 @@ window.__ModuleLoader__.load({
|
|
|
1033
1033
|
run: () => runClean(confirmedTasks) });
|
|
1034
1034
|
};
|
|
1035
1035
|
|
|
1036
|
-
return h('div', { className: 'dsh-
|
|
1036
|
+
return h('div', { className: 'dsh-broom' },
|
|
1037
1037
|
h(Style, null),
|
|
1038
|
-
h('div', { className: 'dsh-
|
|
1039
|
-
className: 'dsh-
|
|
1038
|
+
h('div', { className: 'dsh-broom-header' }, h(SegmentedTabs, {
|
|
1039
|
+
className: 'dsh-broom-tabs', size: 'sm', label: workspaceT('actions.archive'), value: tab,
|
|
1040
1040
|
items: [['sessions', tabLabels.sessions], ['recycled', tabLabels.recycled], ['residue', tabLabels.residue]]
|
|
1041
|
-
.map(([value, label]) => ({ value, label, id: `dsh-
|
|
1041
|
+
.map(([value, label]) => ({ value, label, id: `dsh-broom-tab-${value}`, panelId: `dsh-broom-panel-${value}` })),
|
|
1042
1042
|
onChange: (key) => { if (busy) return; setTab(key); setChecked(new Set()); setQuery(''); setSearchCollapsed(new Set()); setDialog(null); },
|
|
1043
1043
|
}),
|
|
1044
|
-
h('div', { className: 'dsh-
|
|
1045
|
-
h(Input, { className: 'dsh-
|
|
1044
|
+
h('div', { className: 'dsh-broom-search' },
|
|
1045
|
+
h(Input, { className: 'dsh-broom-search-input', icon: officialIcon('search-outline', 16),
|
|
1046
1046
|
type: 'search', value: query, placeholder: searchPlaceholder, 'aria-label': searchPlaceholder,
|
|
1047
1047
|
onChange: (event) => { setQuery(event.target.value); setSearchCollapsed(new Set()); } }),
|
|
1048
1048
|
h(Button, { variant: 'ghost', size: 'sm', disabled: !ready || allKeys.length === 0,
|
|
1049
1049
|
onClick: toggleVisible }, allSelected ? t('selection.deselectAll') : t('selection.selectAll')))),
|
|
1050
|
-
!overview ? h('div', { className: 'dsh-
|
|
1050
|
+
!overview ? h('div', { className: 'dsh-broom-body dsh-broom-state' },
|
|
1051
1051
|
loadError ? [t(loadError === 'host-version' ? 'host.updateRequired' : 'load.failed'), ' ', h(Button, { variant: 'outline', size: 'sm', onClick: () => { setLoadError(false); void refresh(); } }, t('retry'))] : t('loading')) : null,
|
|
1052
|
-
overview && tab !== 'residue' ? h('div', { className: 'dsh-
|
|
1053
|
-
visibleItems.length === 0 ? h('p', { className: 'dsh-
|
|
1052
|
+
overview && tab !== 'residue' ? h('div', { className: 'dsh-broom-body', role: 'tabpanel', id: `dsh-broom-panel-${tab}`, 'aria-labelledby': `dsh-broom-tab-${tab}` },
|
|
1053
|
+
visibleItems.length === 0 ? h('p', { className: 'dsh-broom-state' }, query.trim() ? workspaceT('empty.noMatches')
|
|
1054
1054
|
: (tab === 'sessions' ? workspaceT('empty.none') : workspaceT('empty.noneArchived'))) :
|
|
1055
1055
|
h(HoverCardGroup, null, ...renderGroups(visibleItems, (x, check) => sessionCard(x, t, check, workspaceT), ui,
|
|
1056
1056
|
{ collapsible: true, t, workspaceT }))) : null,
|
|
1057
|
-
overview && tab === 'residue' ? h('div', { className: 'dsh-
|
|
1058
|
-
visibleResidue.length === 0 ? h('p', { className: 'dsh-
|
|
1057
|
+
overview && tab === 'residue' ? h('div', { className: 'dsh-broom-body', role: 'tabpanel', id: `dsh-broom-panel-${tab}`, 'aria-labelledby': `dsh-broom-tab-${tab}` },
|
|
1058
|
+
visibleResidue.length === 0 ? h('p', { className: 'dsh-broom-state' }, query.trim() ? workspaceT('empty.noMatches') : t('empty.residue')) :
|
|
1059
1059
|
h(HoverCardGroup, null, ...renderResidueGroups(visibleResidue, ui, t, workspaceT))) : null,
|
|
1060
|
-
h('div', { className: 'dsh-
|
|
1060
|
+
h('div', { className: 'dsh-broom-foot' },
|
|
1061
1061
|
dialog?.kind === 'taskDetail' ? h(Modal, {
|
|
1062
|
-
open: true, onClose: () => setDialog(null), closeLabel: scheduleT('detail.close'), className: 'dsh-
|
|
1062
|
+
open: true, onClose: () => setDialog(null), closeLabel: scheduleT('detail.close'), className: 'dsh-broom-dialog',
|
|
1063
1063
|
title: scheduleT('detail.label'),
|
|
1064
1064
|
footer: h(Button, { variant: 'outline', onClick: () => setDialog(null) }, workspaceT('close')),
|
|
1065
|
-
}, h('dl', { className: 'dsh-
|
|
1065
|
+
}, h('dl', { className: 'dsh-broom-task-detail' },
|
|
1066
1066
|
...[
|
|
1067
1067
|
[scheduleT('detail.name'), dialog.task.title],
|
|
1068
1068
|
[scheduleT('detail.instruction'), dialog.task.prompt],
|
|
@@ -1074,42 +1074,42 @@ window.__ModuleLoader__.load({
|
|
|
1074
1074
|
: dialog.task.target?.kind === 'new_once' ? 'host.targetNewOnce' : 'host.targetNew')],
|
|
1075
1075
|
].flatMap(([label, value], index) => [h('dt', { key: `label-${index}` }, label), h('dd', { key: `value-${index}` }, value)])))
|
|
1076
1076
|
: dialog?.kind === 'archiveActive' ? h(Modal, {
|
|
1077
|
-
open: true, onClose: () => { if (!busy) dialog.next(); }, closeLabel: workspaceT('close'), className: 'dsh-
|
|
1077
|
+
open: true, onClose: () => { if (!busy) dialog.next(); }, closeLabel: workspaceT('close'), className: 'dsh-broom-dialog',
|
|
1078
1078
|
title: workspaceT('archive.confirm.title'),
|
|
1079
1079
|
description: workspaceT('archive.confirm.desc', { title: dialog.item.title || dialog.item.id }),
|
|
1080
1080
|
footer: h(React.Fragment, null,
|
|
1081
1081
|
h(Button, { variant: 'outline', disabled: busy, onClick: dialog.next, 'data-modal-autofocus': '' }, workspaceT('cancel')),
|
|
1082
|
-
h(Button, { variant: 'outline', className: 'dsh-
|
|
1082
|
+
h(Button, { variant: 'outline', className: 'dsh-broom-danger', disabled: busy, onClick: dialog.run },
|
|
1083
1083
|
workspaceT(busy ? 'archive.confirm.pending' : 'archive.confirm.action'))),
|
|
1084
1084
|
}, h('ul', { 'aria-label': workspaceT('archive.confirm.activity') },
|
|
1085
1085
|
...dialog.item.activity.map((entry, index) => h('li', { key: index }, archiveActivityLine(entry, workspaceT)))),
|
|
1086
1086
|
dialog.item.activity.some((entry) => entry.kind === 'schedule') ? h('p', { role: 'note' }, t('archive.scheduleDeletion')) : null)
|
|
1087
1087
|
: dialog ? h(Modal, {
|
|
1088
|
-
open: true, className: 'dsh-
|
|
1088
|
+
open: true, className: 'dsh-broom-dialog', title: dialog.text,
|
|
1089
1089
|
description: dialog.kind === 'purge' ? t('confirm.purge.description') : dialog.taskNames?.length ? t('confirm.tasks.description') : undefined,
|
|
1090
1090
|
closeLabel: workspaceT('close'), onClose: () => setDialog(null),
|
|
1091
|
-
footer: h('div', { className: 'dsh-
|
|
1091
|
+
footer: h('div', { className: 'dsh-broom-confirm-actions' },
|
|
1092
1092
|
h(Button, { variant: 'outline', onClick: () => setDialog(null), 'data-modal-autofocus': '' }, scheduleT('delete.cancel')),
|
|
1093
|
-
h(Button, { variant: 'outline', className: 'dsh-
|
|
1093
|
+
h(Button, { variant: 'outline', className: 'dsh-broom-danger',
|
|
1094
1094
|
onClick: async () => { const d = dialog; setDialog(null); await d.run(); } }, scheduleT(dialog.kind === 'purge' ? 'delete.confirm' : 'clear.confirm'))),
|
|
1095
|
-
}, dialog.taskNames?.length ? h('div', { className: 'dsh-
|
|
1095
|
+
}, dialog.taskNames?.length ? h('div', { className: 'dsh-broom-confirm-tasks' },
|
|
1096
1096
|
h('ul', null, ...dialog.taskNames.map((name, index) => h('li', { key: index }, name)))) : null)
|
|
1097
1097
|
: null,
|
|
1098
1098
|
notice ? h(Toast, { key: notice.seq, text: notice.text, actions: notice.actions,
|
|
1099
1099
|
...(notice.warning ? { icon: officialIcon('warning-outline', 16), holdMs: 8000 } : { tone: 'success', ...(notice.actions ? { holdMs: 6000 } : {}) }),
|
|
1100
1100
|
onDone: () => setNotice((current) => current?.seq === notice.seq ? null : current) }) : null,
|
|
1101
1101
|
h(React.Fragment, null,
|
|
1102
|
-
h('span', { className: 'dsh-
|
|
1102
|
+
h('span', { className: 'dsh-broom-foot-info' },
|
|
1103
1103
|
fill(t('selection.summary'), { n: checked.size, size: formatBytes(selectedBytes) })),
|
|
1104
1104
|
tab === 'sessions' ? h(Button, { variant: 'outline', disabled: !ready || selectedSessionIds.length === 0,
|
|
1105
1105
|
onClick: runArchive }, workspaceT('actions.archive')) : null,
|
|
1106
1106
|
tab === 'recycled' ? [
|
|
1107
1107
|
h(Button, { key: 'restore', variant: 'outline', disabled: !ready || selectedSessionIds.length === 0,
|
|
1108
1108
|
onClick: runRestore }, workspaceT('actions.unarchive')),
|
|
1109
|
-
h(Button, { key: 'action.purge', variant: 'outline', className: 'dsh-
|
|
1109
|
+
h(Button, { key: 'action.purge', variant: 'outline', className: 'dsh-broom-danger', disabled: !ready || selectedSessionIds.length === 0,
|
|
1110
1110
|
onClick: () => setDialog({ kind: 'purge', text: t('confirm.purge.title', { provider: t('tabs.archived') }), run: runPurge }) }, t('action.purge')),
|
|
1111
1111
|
] : null,
|
|
1112
|
-
tab === 'residue' ? h(Button, { variant: 'outline', className: 'dsh-
|
|
1112
|
+
tab === 'residue' ? h(Button, { variant: 'outline', className: 'dsh-broom-danger', disabled: !ready || checked.size === 0,
|
|
1113
1113
|
onClick: confirmResidue }, t('action.clean')) : null)));
|
|
1114
1114
|
}
|
|
1115
1115
|
|
|
@@ -1120,14 +1120,14 @@ window.__ModuleLoader__.load({
|
|
|
1120
1120
|
const status = sessionStatuses(x)[0];
|
|
1121
1121
|
return {
|
|
1122
1122
|
main: [
|
|
1123
|
-
x.protected ? h('span', { className: 'dsh-
|
|
1124
|
-
...(x.live && !x.protected ? [h('span', { className: 'dsh-
|
|
1125
|
-
h('span', { className: 'dsh-
|
|
1126
|
-
h('span', { className: 'dsh-
|
|
1127
|
-
h('span', { className: 'dsh-
|
|
1123
|
+
x.protected ? h('span', { className: 'dsh-broom-lead', 'aria-label': t('protection.label') }, officialIcon('shield-outline', 14)) : checkNode,
|
|
1124
|
+
...(x.live && !x.protected ? [h('span', { className: 'dsh-broom-lead', 'aria-label': workspaceT(status.key, status.params) }, h(StateDot, { state: status.state }))] : []),
|
|
1125
|
+
h('span', { className: 'dsh-broom-title' }, x.blank === true ? workspaceT('session.new') : x.title),
|
|
1126
|
+
h('span', { className: 'dsh-broom-row-side has-columns' },
|
|
1127
|
+
h('span', { className: 'dsh-broom-marker', ...(x.purgeBlock && !x.protected ? { 'aria-label': t(x.purgeBlock === 'schedule_reference' ? 'reference.schedule' : 'error.referenceCheck') } : { 'aria-hidden': true }) },
|
|
1128
1128
|
x.purgeBlock && !x.protected ? officialIcon('shield-outline', 14) : null),
|
|
1129
|
-
h('span', { className: 'dsh-
|
|
1130
|
-
h('span', { className: 'dsh-
|
|
1129
|
+
h('span', { className: 'dsh-broom-size' }, typeof x.sizeBytes === 'number' ? formatBytes(x.sizeBytes) : ''),
|
|
1130
|
+
h('span', { className: 'dsh-broom-time' }, time)),
|
|
1131
1131
|
],
|
|
1132
1132
|
};
|
|
1133
1133
|
}
|
|
@@ -1137,14 +1137,14 @@ window.__ModuleLoader__.load({
|
|
|
1137
1137
|
const anchorRef = { current: null };
|
|
1138
1138
|
const button = h('button', {
|
|
1139
1139
|
ref: anchorRef,
|
|
1140
|
-
type: 'button', className: 'dsh-
|
|
1140
|
+
type: 'button', className: 'dsh-broom-group-name',
|
|
1141
1141
|
onClick: () => ui.onToggleCollapse(key), 'aria-expanded': !isCollapsed,
|
|
1142
1142
|
},
|
|
1143
|
-
h('span', { className: 'dsh-
|
|
1144
|
-
officialIcon(`folder-${isCollapsed ? 'close' : 'open'}`, 16, 'dsh-
|
|
1145
|
-
officialIcon('triangle-right-fill', 14, `dsh-
|
|
1146
|
-
h('span', { className: 'dsh-
|
|
1147
|
-
return h('div', { className: 'dsh-
|
|
1143
|
+
h('span', { className: 'dsh-broom-group-icon', 'aria-hidden': true },
|
|
1144
|
+
officialIcon(`folder-${isCollapsed ? 'close' : 'open'}`, 16, 'dsh-broom-folder'),
|
|
1145
|
+
officialIcon('triangle-right-fill', 14, `dsh-broom-chevron${isCollapsed ? '' : ' is-open'}`)),
|
|
1146
|
+
h('span', { className: 'dsh-broom-group-label' }, title));
|
|
1147
|
+
return h('div', { className: 'dsh-broom-group-title' }, path && createdAt != null && Number.isFinite(new Date(createdAt).getTime())
|
|
1148
1148
|
? rowWithHover(`workspace:${key}`, button, cardContent({ anchorRef, title, path: displayPath(path, ui.home),
|
|
1149
1149
|
time: workspaceCreatedLabel(createdAt, workspaceT) }, workspaceT), workspaceT, path)
|
|
1150
1150
|
: button);
|
|
@@ -1160,18 +1160,18 @@ window.__ModuleLoader__.load({
|
|
|
1160
1160
|
}
|
|
1161
1161
|
return [...byWs.entries()].map(([wsKey, group]) => {
|
|
1162
1162
|
const isCollapsed = collapsible && ui.collapsed.has(wsKey);
|
|
1163
|
-
return h('div', { key: wsKey, className: 'dsh-
|
|
1163
|
+
return h('div', { key: wsKey, className: 'dsh-broom-group' },
|
|
1164
1164
|
groupHeading(wsKey, group.title, isCollapsed, ui, group.path, group.createdAt, workspaceT),
|
|
1165
1165
|
isCollapsed ? null : group.list.map((x) => {
|
|
1166
1166
|
const anchorRef = { current: null };
|
|
1167
1167
|
const blocked = x.protected;
|
|
1168
|
-
const card = cardOf(x, blocked ? h('span', { className: 'dsh-
|
|
1169
|
-
type: 'checkbox', className: 'dsh-
|
|
1168
|
+
const card = cardOf(x, blocked ? h('span', { className: 'dsh-broom-lead' }, '·') : h('input', {
|
|
1169
|
+
type: 'checkbox', className: 'dsh-broom-check', checked: ui.checked.has(x.id),
|
|
1170
1170
|
onChange: () => ui.onSelect(x.id, !ui.checked.has(x.id)), 'aria-label': x.title,
|
|
1171
1171
|
}));
|
|
1172
|
-
const row = h('label', { ref: anchorRef, className: `dsh-
|
|
1172
|
+
const row = h('label', { ref: anchorRef, className: `dsh-broom-row${blocked ? ' is-static' : ''}${x.archived ? ' is-archived' : ''}${ui.checked.has(x.id) ? ' is-selected' : ''}`,
|
|
1173
1173
|
onPointerEnter: titleEnter, onPointerLeave: titleLeave },
|
|
1174
|
-
h('div', { className: 'dsh-
|
|
1174
|
+
h('div', { className: 'dsh-broom-row-main' }, ...card.main));
|
|
1175
1175
|
const timestamp = sessionTime(x);
|
|
1176
1176
|
return rowWithHover(x.id, row, cardContent({ anchorRef, title: x.title, path: displayPath(x.cwd || x.workspacePath, ui.home),
|
|
1177
1177
|
time: x.blank ? '' : hoverTime(timestamp, workspaceT),
|
|
@@ -1198,21 +1198,21 @@ window.__ModuleLoader__.load({
|
|
|
1198
1198
|
return [...byWorkspace].map(([workspaceKey, group]) => {
|
|
1199
1199
|
const key = `residue:workspace:${workspaceKey}`;
|
|
1200
1200
|
const isCollapsed = ui.collapsed.has(key);
|
|
1201
|
-
return h('div', { key, className: 'dsh-
|
|
1201
|
+
return h('div', { key, className: 'dsh-broom-group' },
|
|
1202
1202
|
groupHeading(key, group.title, isCollapsed, ui, group.path, group.createdAt, workspaceT),
|
|
1203
1203
|
isCollapsed ? null : group.entries.map((item) => {
|
|
1204
1204
|
const anchorRef = { current: null };
|
|
1205
1205
|
const reason = item.kind === 'orphan-task' ? t('residue.orphanTask') : item.relatedRegistration ? t('residue.registeredCache') : '';
|
|
1206
1206
|
const row = h('label', { ref: anchorRef, onPointerEnter: titleEnter, onPointerLeave: titleLeave,
|
|
1207
|
-
className: `dsh-
|
|
1208
|
-
h('div', { className: 'dsh-
|
|
1209
|
-
h('input', { type: 'checkbox', className: 'dsh-
|
|
1207
|
+
className: `dsh-broom-row${ui.checked.has(item.key) ? ' is-selected' : ''}` },
|
|
1208
|
+
h('div', { className: 'dsh-broom-row-main' },
|
|
1209
|
+
h('input', { type: 'checkbox', className: 'dsh-broom-check', checked: ui.checked.has(item.key),
|
|
1210
1210
|
onChange: () => ui.onSelect(item.key, !ui.checked.has(item.key)), 'aria-label': item.label }),
|
|
1211
|
-
h('span', { className: 'dsh-
|
|
1212
|
-
h('span', { className: 'dsh-
|
|
1213
|
-
h('span', { className: 'dsh-
|
|
1214
|
-
h('span', { className: 'dsh-
|
|
1215
|
-
h('span', { className: 'dsh-
|
|
1211
|
+
h('span', { className: 'dsh-broom-title' }, item.label),
|
|
1212
|
+
h('span', { className: 'dsh-broom-row-side has-columns' },
|
|
1213
|
+
h('span', { className: 'dsh-broom-marker', 'aria-hidden': true }, item.kind === 'orphan-task' ? officialIcon('clock-outline', 14) : null),
|
|
1214
|
+
h('span', { className: 'dsh-broom-size' }, typeof item.sizeBytes === 'number' ? formatBytes(item.sizeBytes) : ''),
|
|
1215
|
+
h('span', { className: 'dsh-broom-time' }, residueTime(item) > 0 ? relativeTime(residueTime(item), workspaceT) : ''))));
|
|
1216
1216
|
return rowWithHover(item.key, row, cardContent({ anchorRef, title: item.label,
|
|
1217
1217
|
path: displayPath(item.kind === 'orphan-task' ? item.targetSessionId : item.workspacePath || (item.id !== item.label ? item.id : ''), ui.home),
|
|
1218
1218
|
time: hoverTime(residueTime(item), workspaceT), reason,
|
|
@@ -1226,70 +1226,70 @@ window.__ModuleLoader__.load({
|
|
|
1226
1226
|
/** 组件内样式:随组件卸载移除,仅用官方主题令牌。 */
|
|
1227
1227
|
function Style() {
|
|
1228
1228
|
return h('style', null, `
|
|
1229
|
-
.dsh-
|
|
1230
|
-
.dsh-
|
|
1231
|
-
.dsh-
|
|
1232
|
-
.dsh-
|
|
1233
|
-
.dsh-
|
|
1234
|
-
.dsh-
|
|
1235
|
-
.dsh-
|
|
1236
|
-
.dsh-
|
|
1237
|
-
.dsh-
|
|
1238
|
-
.dsh-
|
|
1239
|
-
.dsh-
|
|
1240
|
-
.dsh-
|
|
1241
|
-
.dsh-
|
|
1242
|
-
.dsh-
|
|
1243
|
-
.dsh-
|
|
1229
|
+
.dsh-broom { display: flex; flex-direction: column; height: 100%; min-height: 0; min-width: 0; font-family: var(--dsw-font-family, inherit); font-size: var(--dsh-content-font-size, 14px); line-height: 1.5; color: var(--dsw-alias-label-primary); }
|
|
1230
|
+
.dsh-broom *, .dsh-broom *::before, .dsh-broom *::after { box-sizing: border-box; }
|
|
1231
|
+
.dsh-broom button, .dsh-broom input { font-family: inherit; }
|
|
1232
|
+
.dsh-broom-body { flex: 1 1 0; min-width: 0; min-height: 0; overflow-y: auto; overflow-x: hidden; }
|
|
1233
|
+
.dsh-broom-header { flex: none; min-width: 0; padding-top: 8px; }
|
|
1234
|
+
.dsh-broom-state { padding: 32px 0; text-align: center; color: var(--dsw-alias-label-secondary); }
|
|
1235
|
+
.dsh-broom-search { display: flex; align-items: center; gap: 8px; margin: 14px 0 8px; min-width: 0; }
|
|
1236
|
+
.dsh-broom-search-input { flex: 1 1 240px; min-width: 0; }
|
|
1237
|
+
.dsh-broom-tabs { align-self: flex-start; max-width: 100%; }
|
|
1238
|
+
.dsh-broom-group + .dsh-broom-group { margin-top: 4px; }
|
|
1239
|
+
.dsh-broom-group > * + * { margin-top: 2px; }
|
|
1240
|
+
.dsh-broom-group-title { display: flex; align-items: center; width: 100%; }
|
|
1241
|
+
.dsh-broom-group-title > span:has(> .dsh-broom-group-name) { display: block; width: 100%; }
|
|
1242
|
+
.dsh-broom-group-name { display: flex; align-items: center; gap: 6px; width: 100%; min-width: 0; height: 32px; padding: 0 8px; border: 0; border-radius: var(--dsw-radius-md, 8px); background: transparent; color: var(--dsw-alias-label-primary); font-size: 14px; line-height: 20px; cursor: pointer; text-align: left; }
|
|
1243
|
+
.dsh-broom-group-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1244
1244
|
/* Official compact card is portaled above the settings panel. */
|
|
1245
|
-
span[data-dsh-
|
|
1246
|
-
.dsh-
|
|
1247
|
-
.dsh-
|
|
1248
|
-
.dsh-
|
|
1249
|
-
.dsh-
|
|
1250
|
-
.dsh-
|
|
1251
|
-
.dsh-
|
|
1252
|
-
.dsh-
|
|
1253
|
-
.dsh-
|
|
1254
|
-
.dsh-
|
|
1255
|
-
.dsh-
|
|
1256
|
-
.dsh-
|
|
1257
|
-
.dsh-
|
|
1258
|
-
.dsh-
|
|
1259
|
-
.dsh-
|
|
1260
|
-
.dsh-
|
|
1261
|
-
.dsh-
|
|
1262
|
-
@media (hover: hover) { .dsh-
|
|
1263
|
-
@media (prefers-reduced-motion: reduce) { .dsh-
|
|
1264
|
-
.dsh-
|
|
1265
|
-
.dsh-
|
|
1266
|
-
.dsh-
|
|
1267
|
-
.dsh-
|
|
1268
|
-
.dsh-
|
|
1269
|
-
.dsh-
|
|
1270
|
-
.dsh-
|
|
1271
|
-
.dsh-
|
|
1272
|
-
.dsh-
|
|
1273
|
-
.dsh-
|
|
1274
|
-
.dsh-
|
|
1275
|
-
.dsh-
|
|
1276
|
-
.dsh-
|
|
1277
|
-
.dsh-
|
|
1278
|
-
@media (hover: hover) { .dsh-
|
|
1279
|
-
.dsh-
|
|
1280
|
-
.dsh-
|
|
1281
|
-
.dsh-
|
|
1282
|
-
.dsh-
|
|
1283
|
-
.dsh-
|
|
1284
|
-
.dsh-
|
|
1285
|
-
.dsh-
|
|
1286
|
-
.dsh-
|
|
1287
|
-
.dsh-
|
|
1288
|
-
.dsh-
|
|
1289
|
-
div:has(> .dsh-
|
|
1290
|
-
.dsh-
|
|
1291
|
-
.dsh-
|
|
1292
|
-
.dsh-
|
|
1245
|
+
span[data-dsh-broom-positioned] > div { z-index: 1001; max-width: calc(100vw - 16px); left: var(--dsh-broom-card-left) !important; }
|
|
1246
|
+
.dsh-broom-hover-content { display: flex; flex-direction: column; gap: 8px; }
|
|
1247
|
+
.dsh-broom-hover-title { color: var(--dsw-alias-hovercard-label-primary); font-size: 14px; line-height: 20px; overflow-wrap: break-word; }
|
|
1248
|
+
.dsh-broom-hover-path { color: var(--dsw-alias-hovercard-label-secondary); font-size: 12px; line-height: 16px; word-break: break-all; }
|
|
1249
|
+
.dsh-broom-hover-time { color: var(--dsw-alias-hovercard-label-secondary); font-size: 12px; line-height: 16px; }
|
|
1250
|
+
.dsh-broom-hover-status { display: flex; align-items: center; gap: 8px; color: var(--dsw-alias-hovercard-label-tertiary); font-size: 12px; line-height: 20px; }
|
|
1251
|
+
.dsh-broom-hover-status span { min-width: 0; overflow-wrap: break-word; }
|
|
1252
|
+
.dsh-broom-hover-archived > svg { flex-shrink: 0; margin: 0 -4px; }
|
|
1253
|
+
.dsh-broom-hover-task-button { width: 100%; padding: 0; border: 0; background: transparent; font-family: inherit; text-align: left; cursor: pointer; }
|
|
1254
|
+
.dsh-broom-hover-task-button:hover { color: var(--dsw-alias-hovercard-label-primary); }
|
|
1255
|
+
.dsh-broom-hover-task-button:focus-visible { outline: var(--dsw-focus-ring-width, 2px) solid var(--dsw-focus-ring-color, currentColor); outline-offset: 2px; }
|
|
1256
|
+
.dsh-broom-hover-task-button:disabled { cursor: default; }
|
|
1257
|
+
.dsh-broom-group-icon { flex: 0 0 16px; width: 16px; height: 20px; display: inline-flex; align-items: center; justify-content: center; color: var(--dsw-alias-label-tertiary); }
|
|
1258
|
+
.dsh-broom-folder { width: 16px; height: 16px; }
|
|
1259
|
+
.dsh-broom-chevron { width: 14px; height: 14px; }
|
|
1260
|
+
.dsh-broom-chevron { display: none; color: var(--dsw-alias-label-caption); transition: transform 150ms var(--ds-ease-in-out, ease-in-out); }
|
|
1261
|
+
.dsh-broom-chevron.is-open { transform: rotate(90deg); }
|
|
1262
|
+
@media (hover: hover) { .dsh-broom-group-name:hover { background: var(--dsw-alias-interactive-bg-hover, var(--dsw-alias-bg-layer-2)); } .dsh-broom-group-name:hover .dsh-broom-folder { display: none; } .dsh-broom-group-name:hover .dsh-broom-chevron { display: block; } }
|
|
1263
|
+
@media (prefers-reduced-motion: reduce) { .dsh-broom-chevron { transition: none; } }
|
|
1264
|
+
.dsh-broom-row { display: flex; align-items: center; height: 32px; padding: 0 8px 0 24px; border-radius: var(--dsw-radius-md, 8px); cursor: pointer; }
|
|
1265
|
+
.dsh-broom-row:hover, .dsh-broom-row.is-selected { background: var(--dsw-alias-interactive-bg-hover, var(--dsw-alias-bg-layer-2)); }
|
|
1266
|
+
.dsh-broom-row.is-static { cursor: default; }
|
|
1267
|
+
.dsh-broom-row.is-static:hover { background: transparent; }
|
|
1268
|
+
.dsh-broom-row-main { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; }
|
|
1269
|
+
.dsh-broom-row-side { margin-left: auto; color: var(--dsw-alias-label-tertiary); font-size: 10px; line-height: 16px; white-space: nowrap; }
|
|
1270
|
+
.dsh-broom-row-side.has-columns { flex: 0 0 min(136px, 50%); min-width: 0; display: grid; grid-template-columns: 16px minmax(0, 1fr) minmax(0, 1fr); column-gap: 6px; align-items: center; text-align: right; }
|
|
1271
|
+
.dsh-broom-marker { width: 16px; height: 20px; display: inline-flex; align-items: center; justify-content: center; }
|
|
1272
|
+
.dsh-broom-size, .dsh-broom-time { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
|
1273
|
+
.dsh-broom-check { flex: 0 0 auto; width: 16px; height: 16px; margin: 0; accent-color: var(--dsw-alias-brand-primary); }
|
|
1274
|
+
.dsh-broom-check:focus-visible { outline: var(--dsw-focus-ring-width, 2px) solid var(--dsw-focus-ring-color, var(--dsw-alias-brand-primary)); outline-offset: 2px; }
|
|
1275
|
+
.dsh-broom-lead { flex: 0 0 16px; display: inline-flex; align-items: center; justify-content: center; color: var(--dsw-alias-label-secondary); }
|
|
1276
|
+
.dsh-broom-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; line-height: 20px; }
|
|
1277
|
+
.dsh-broom-row.is-archived .dsh-broom-title { color: var(--dsw-alias-label-caption); }
|
|
1278
|
+
@media (hover: hover) { .dsh-broom-row:hover .dsh-broom-title { text-overflow: clip; } }
|
|
1279
|
+
.dsh-broom-title[data-scrolled] { mask-image: linear-gradient(to right, transparent, #000 12px); }
|
|
1280
|
+
.dsh-broom-title[data-clipped] { mask-image: linear-gradient(to left, transparent, #000 12px); }
|
|
1281
|
+
.dsh-broom-title[data-scrolled][data-clipped] { mask-image: linear-gradient(to right, transparent, #000 12px, #000 calc(100% - 12px), transparent); }
|
|
1282
|
+
.dsh-broom-foot { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 0 0; border-top: 0.5px solid var(--dsw-alias-border-l2); }
|
|
1283
|
+
.dsh-broom-foot-info { flex: 1 1 100px; color: var(--dsw-alias-label-secondary); font-size: .86em; }
|
|
1284
|
+
.dsh-broom-group-name:focus-visible { outline: var(--dsw-focus-ring-width, 2px) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary)); outline-offset: 2px; }
|
|
1285
|
+
.dsh-broom-danger { color: var(--dsw-alias-state-error-primary); --dsh-button-outline-color: var(--dsw-alias-state-error-primary); }
|
|
1286
|
+
.dsh-broom-confirm-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
|
|
1287
|
+
.dsh-broom-confirm-tasks { min-width: 0; }
|
|
1288
|
+
.dsh-broom-confirm-tasks ul { margin: 4px 0 0; padding-left: 20px; }
|
|
1289
|
+
div:has(> .dsh-broom-dialog) { z-index: 1002; }
|
|
1290
|
+
.dsh-broom-task-detail { display: grid; gap: 6px; margin: 0; font-size: 14px; }
|
|
1291
|
+
.dsh-broom-task-detail dt { color: var(--dsw-alias-label-secondary); }
|
|
1292
|
+
.dsh-broom-task-detail dd { margin: 0 0 10px; white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
1293
1293
|
`);
|
|
1294
1294
|
}
|
|
1295
1295
|
|
|
@@ -1307,7 +1307,7 @@ div:has(> .dsh-clean-dialog) { z-index: 1002; }
|
|
|
1307
1307
|
const t = officialTranslator(ctx.locale);
|
|
1308
1308
|
ctx.slots.inject('settings.section', () => ctx.slots.register({
|
|
1309
1309
|
name: 'settings.section',
|
|
1310
|
-
id: 'dsh-
|
|
1310
|
+
id: 'dsh-broom',
|
|
1311
1311
|
order: 60,
|
|
1312
1312
|
label: () => ctx.locale.bind('workspace')('actions.archive'),
|
|
1313
1313
|
locale: NS,
|
|
@@ -1329,7 +1329,7 @@ div:has(> .dsh-clean-dialog) { z-index: 1002; }
|
|
|
1329
1329
|
}, Section));
|
|
1330
1330
|
ctx.slots.inject('settings.section.icon', () => ctx.slots.register({
|
|
1331
1331
|
name: 'settings.section.icon',
|
|
1332
|
-
id: 'dsh-
|
|
1332
|
+
id: 'dsh-broom',
|
|
1333
1333
|
}, NavIcon));
|
|
1334
1334
|
},
|
|
1335
1335
|
};
|
package/cordis.patch.yml
CHANGED
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** dsh-
|
|
1
|
+
/** dsh-broom 宿主半边:清理遗留会话数据,经 connection.fetch 路由暴露给浏览器。 */
|
|
2
2
|
import { registerRoutes } from './lib/routes.mjs';
|
|
3
3
|
import { isPurgingSession, isExternalUnarchive } from './lib/clean.mjs';
|
|
4
4
|
import { cleanError } from './lib/errors.mjs';
|
|
@@ -20,6 +20,6 @@ export function apply(ctx, rawConfig = {}) {
|
|
|
20
20
|
if (isPurgingSession(session.id)) throw cleanError('purge_busy');
|
|
21
21
|
});
|
|
22
22
|
return () => { stopUnarchive(); stopCreate(); };
|
|
23
|
-
}, 'dsh-
|
|
23
|
+
}, 'dsh-broom: purge coordination');
|
|
24
24
|
registerRoutes(ctx, config);
|
|
25
25
|
}
|
package/lib/clean.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** dsh-
|
|
1
|
+
/** dsh-broom · 永久删除:日志目录、投影缓存、工作区注册一并清除,不留自有数据。 */
|
|
2
2
|
import { lstat, readdir, realpath, rmdir, unlink } from 'node:fs/promises';
|
|
3
3
|
import { dirname, resolve } from 'node:path';
|
|
4
4
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
package/lib/errors.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Stable error identity; presentation and translation belong to the client. */
|
|
2
2
|
export function cleanError(code, cause) {
|
|
3
|
-
return Object.assign(new Error(`dsh-
|
|
3
|
+
return Object.assign(new Error(`dsh-broom:${code}`, cause === undefined ? undefined : { cause }), { cleanCode: code });
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
export function reject(code, cause) { throw cleanError(code, cause); }
|
package/lib/guard.mjs
CHANGED
package/lib/home.mjs
CHANGED
package/lib/routes.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* dsh-
|
|
2
|
+
* dsh-broom · connection.fetch 路由
|
|
3
3
|
*
|
|
4
4
|
* 认证与 peer 准入由载体层负责(仅 owner peer 可达精确路由)。
|
|
5
5
|
* overview / archive / purge / unarchive / residue 路由。
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { buildOverview } from './store.mjs';
|
|
8
8
|
import { purgeSessions, cleanResidue, listResidue } from './clean.mjs';
|
|
9
9
|
|
|
10
|
-
const PREFIX = '/api/dsh-
|
|
10
|
+
const PREFIX = '/api/dsh-broom';
|
|
11
11
|
|
|
12
12
|
function json(data, status = 200) {
|
|
13
13
|
return new Response(JSON.stringify(data), {
|
|
@@ -37,14 +37,14 @@ export function registerRoutes(ctx, config) {
|
|
|
37
37
|
const get = (path, handler) => ctx.effect(() => ctx.connection.fetch.register({
|
|
38
38
|
path: `${PREFIX}.${path}`, methods: ['GET', 'HEAD'], requestBody: 'buffered',
|
|
39
39
|
fetch: async (request) => (request.method === 'HEAD' ? new Response(null, { status: 200 }) : handler(request)),
|
|
40
|
-
}), `dsh-
|
|
40
|
+
}), `dsh-broom: ${PREFIX}.${path}`);
|
|
41
41
|
const post = (path, handler) => ctx.effect(() => ctx.connection.fetch.register({
|
|
42
42
|
path: `${PREFIX}.${path}`, methods: ['POST'], requestBody: 'buffered',
|
|
43
43
|
fetch: async (request) => {
|
|
44
44
|
try { return await handler(await readJsonBody(request)); }
|
|
45
45
|
catch (error) { return json({ error: String(error?.message ?? error) }, 500); }
|
|
46
46
|
},
|
|
47
|
-
}), `dsh-
|
|
47
|
+
}), `dsh-broom: ${PREFIX}.${path}`);
|
|
48
48
|
|
|
49
49
|
get('overview', async () => {
|
|
50
50
|
const overview = await buildOverview(ctx, config);
|
|
@@ -121,11 +121,11 @@ export function registerRoutes(ctx, config) {
|
|
|
121
121
|
const overview = await buildOverview(ctx, config);
|
|
122
122
|
const session = overview.sessions.find((item) => item.id === sessionId);
|
|
123
123
|
const orphan = (overview.residue.orphanTasks ?? []).some((task) => task.id === id && task.targetSessionId === sessionId);
|
|
124
|
-
if (!session?.scheduleTasks.some((task) => task.id === id) && !orphan) return json({ error: 'dsh-
|
|
124
|
+
if (!session?.scheduleTasks.some((task) => task.id === id) && !orphan) return json({ error: 'dsh-broom:task_not_found' }, 404);
|
|
125
125
|
const schedule = ctx.get('schedule');
|
|
126
|
-
if (!schedule || typeof schedule.view !== 'function') return json({ error: 'dsh-
|
|
126
|
+
if (!schedule || typeof schedule.view !== 'function') return json({ error: 'dsh-broom:task_unavailable' }, 503);
|
|
127
127
|
const task = await schedule.view({ id });
|
|
128
|
-
if (!task || task.code === 'schedule_not_found') return json({ error: 'dsh-
|
|
128
|
+
if (!task || task.code === 'schedule_not_found') return json({ error: 'dsh-broom:task_not_found' }, 404);
|
|
129
129
|
return json({ task });
|
|
130
130
|
});
|
|
131
131
|
|
package/lib/store.mjs
CHANGED