dsh-taskbridge 1.8.0 → 1.8.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/CHANGELOG.md +12 -0
- package/README.md +616 -619
- package/antigravity/agents/dsh-taskbridge.md +12 -11
- package/antigravity/skills/dsh-taskbridge/SKILL.md +15 -15
- package/codex/dsh-taskbridge.toml +22 -11
- package/docs/INTRODUCTION.md +18 -15
- package/docs/INTRODUCTION.zh.md +19 -19
- package/docs/codex-integration.md +2 -2
- package/docs/conversation-placement.md +7 -6
- package/docs/releases/1.8.1.zh.md +24 -0
- package/docs/runtime-compatibility.md +1 -1
- package/docs/taskbridge-upgrade.md +1 -1
- package/lib/client.d.ts +72 -1
- package/lib/client.js +7 -7
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +4 -3
- package/src/antigravity/installer.js +23 -1
- package/src/client/api.js +123 -3
- package/src/client/index.jsx +111 -8
- package/src/client/task-cleanup.js +130 -5
- package/src/codex/installer.js +3 -0
- package/src/config/defaults.js +11 -15
- package/src/http/user-plane.js +11 -1
- package/src/jobs/engine.js +1 -0
- package/src/jobs/history.js +1 -1
- package/src/jobs/plan-store.js +83 -0
- package/src/jobs/record-cleanup.js +452 -7
- package/src/mcp/server.js +30 -26
- package/src/mcp/wait.js +34 -15
- package/src/runtime/agent-runner.js +1 -0
- package/src/runtime/session-placement.js +36 -1
- package/src/runtime/worker-prompt.js +2 -1
- package/src/workspace/worktrees.js +155 -1
package/locale/en.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "DSH TaskBridge",
|
|
4
|
-
"description": "Let Codex and Antigravity direct DSH
|
|
4
|
+
"description": "Let Codex and Antigravity direct DSH through a clean black-box bridge: centralized API/model/effort routing, worktree isolation, one-click client setup, low-overhead quiet waiting, per-call approvals, host review, same-session follow-ups and linked cleanup. Claude Code / Claude Desktop support is planned for 2.0.",
|
|
5
5
|
"detail": "docs/INTRODUCTION.md"
|
|
6
6
|
}
|
|
7
7
|
}
|
package/locale/zh.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "DSH TaskBridge",
|
|
4
|
-
"description": "让 Codex 与 Antigravity 指挥 DSH
|
|
4
|
+
"description": "让 Codex 与 Antigravity 指挥 DSH 落地代码:黑盒封装 API、模型、思考强度与工作树隔离,提供一键客户端集成、低耗静默等待、单次权限审批、集中审查、原会话续接与任务联动清理。Claude Code / Claude Desktop 接入计划于 2.0 上线。",
|
|
5
5
|
"detail": "docs/INTRODUCTION.zh.md"
|
|
6
6
|
}
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-taskbridge",
|
|
3
|
-
"version": "1.8.
|
|
4
|
-
"description": "让 Codex 与 Antigravity 指挥 DSH
|
|
3
|
+
"version": "1.8.1",
|
|
4
|
+
"description": "让 Codex 与 Antigravity 指挥 DSH 落地代码:黑盒封装 API、模型、思考强度与工作树隔离,提供一键客户端集成、低耗静默等待、单次权限审批、集中审查、原会话续接与任务联动清理。Claude Code / Claude Desktop 接入计划于 2.0 上线。",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -80,7 +80,8 @@
|
|
|
80
80
|
"docs/taskbridge-upgrade.md",
|
|
81
81
|
"docs/releases/1.6.0.zh.md",
|
|
82
82
|
"docs/releases/1.7.0.zh.md",
|
|
83
|
-
"docs/releases/1.8.0.zh.md"
|
|
83
|
+
"docs/releases/1.8.0.zh.md",
|
|
84
|
+
"docs/releases/1.8.1.zh.md"
|
|
84
85
|
],
|
|
85
86
|
"dsh": {
|
|
86
87
|
"manifestVersion": 1,
|
|
@@ -588,6 +588,23 @@ async function classifyMcpFile({ mcpPath, desired, recordedDigest }) {
|
|
|
588
588
|
};
|
|
589
589
|
}
|
|
590
590
|
|
|
591
|
+
/**
|
|
592
|
+
* Exact LF SHA-256 digests of prior published Antigravity managed files.
|
|
593
|
+
* Allows an untouched published installation (such as 1.8.0) to be recognized as
|
|
594
|
+
* `outdated` and upgraded cleanly even if the local ownership sidecar is absent,
|
|
595
|
+
* while any operator-edited file still classifies as `modified` and is preserved.
|
|
596
|
+
*/
|
|
597
|
+
const KNOWN_PRIOR_ANTIGRAVITY_FILES = Object.freeze({
|
|
598
|
+
'skills/dsh-taskbridge/SKILL.md': Object.freeze([
|
|
599
|
+
// Published 1.8.0 SKILL.md (LF)
|
|
600
|
+
'9e83135ece937dbc0b73f5098509daac2fe4b973fe4dcd2ed75186745cf3cfee',
|
|
601
|
+
]),
|
|
602
|
+
'agents/dsh-taskbridge.md': Object.freeze([
|
|
603
|
+
// Published 1.8.0 agents/dsh-taskbridge.md (LF)
|
|
604
|
+
'df1418abe2c58c535734ecf6619bd027ca251d2dd6043cec9f41561d8e0a432b',
|
|
605
|
+
]),
|
|
606
|
+
});
|
|
607
|
+
|
|
591
608
|
function isManagedAntigravityManifest(contents) {
|
|
592
609
|
try {
|
|
593
610
|
const parsed = JSON.parse(contents);
|
|
@@ -624,7 +641,12 @@ async function classifyPluginFiles({ paths, templates, recordedFiles }) {
|
|
|
624
641
|
continue;
|
|
625
642
|
}
|
|
626
643
|
const recorded = recordedFiles?.[key] ?? null;
|
|
627
|
-
|
|
644
|
+
const lfDigest = digestLf(file.contents);
|
|
645
|
+
if (typeof recorded === 'string' && lfDigest === recorded) {
|
|
646
|
+
details[key] = { path: targetPath, state: 'outdated', expectDigest: rawDigest };
|
|
647
|
+
continue;
|
|
648
|
+
}
|
|
649
|
+
if (Array.isArray(KNOWN_PRIOR_ANTIGRAVITY_FILES[key]) && KNOWN_PRIOR_ANTIGRAVITY_FILES[key].includes(lfDigest)) {
|
|
628
650
|
details[key] = { path: targetPath, state: 'outdated', expectDigest: rawDigest };
|
|
629
651
|
continue;
|
|
630
652
|
}
|
package/src/client/api.js
CHANGED
|
@@ -33,9 +33,11 @@
|
|
|
33
33
|
// `createStore`'s caller in `index.jsx` to `cleanupProjection()`).
|
|
34
34
|
export {
|
|
35
35
|
CLEANUP_BLOCKER_LABELS,
|
|
36
|
+
CLEANUP_PRESETS,
|
|
36
37
|
MAX_CLEANUP_CHAINS,
|
|
37
38
|
cleanupBlockerLabel,
|
|
38
39
|
cleanupCandidates,
|
|
40
|
+
cleanupConfirmText,
|
|
39
41
|
cleanupOutcome,
|
|
40
42
|
cleanupProjection,
|
|
41
43
|
cleanupRequest,
|
|
@@ -43,7 +45,9 @@ export {
|
|
|
43
45
|
cleanupSelectionSummary,
|
|
44
46
|
cleanupWarningText,
|
|
45
47
|
describeCleanupOutcome,
|
|
48
|
+
describeOrphanCleanupOutcome,
|
|
46
49
|
pruneCleanupSelection,
|
|
50
|
+
selectCleanupCandidatesByPreset,
|
|
47
51
|
toggleCleanupSelection,
|
|
48
52
|
withSelectionState,
|
|
49
53
|
} from './task-cleanup.js';
|
|
@@ -96,6 +100,7 @@ export const ROUTES = Object.freeze({
|
|
|
96
100
|
// execution chains. It is a `POST`, never a load-time or refresh-time write, and it
|
|
97
101
|
// only ever names chains and their exact rounds.
|
|
98
102
|
tasksCleanup: `${USER_PLANE_PREFIX}/tasks/cleanup`,
|
|
103
|
+
tasksCleanupOrphans: `${USER_PLANE_PREFIX}/tasks/cleanup-orphans`,
|
|
99
104
|
// The one planning write the page has: a batch of planning nodes. It creates
|
|
100
105
|
// records only — it cannot dispatch, authorize or review anything.
|
|
101
106
|
plans: `${USER_PLANE_PREFIX}/plans`,
|
|
@@ -357,7 +362,17 @@ export function createApi(options = {}) {
|
|
|
357
362
|
*/
|
|
358
363
|
async cleanupTasks(body) {
|
|
359
364
|
const chains = Array.isArray(body?.chains) ? body.chains : [];
|
|
360
|
-
|
|
365
|
+
const payload = { confirm: true, chains };
|
|
366
|
+
if (body?.archiveSessions === true) payload.archiveSessions = true;
|
|
367
|
+
if (body?.removeWorktrees === true) payload.removeWorktrees = true;
|
|
368
|
+
if (body?.cleanPlans === true) payload.cleanPlans = true;
|
|
369
|
+
return await request('POST', ROUTES.tasksCleanup, payload);
|
|
370
|
+
},
|
|
371
|
+
async cleanupOrphans(options = {}) {
|
|
372
|
+
const payload = { confirm: true };
|
|
373
|
+
if (typeof options?.archiveSessions === 'boolean') payload.archiveSessions = options.archiveSessions;
|
|
374
|
+
if (typeof options?.removeWorktrees === 'boolean') payload.removeWorktrees = options.removeWorktrees;
|
|
375
|
+
return await request('POST', ROUTES.tasksCleanupOrphans, payload);
|
|
361
376
|
},
|
|
362
377
|
/**
|
|
363
378
|
* Create a batch of planning nodes.
|
|
@@ -3786,10 +3801,10 @@ export function createStore(options = {}) {
|
|
|
3786
3801
|
},
|
|
3787
3802
|
|
|
3788
3803
|
/** Remove a confirmed selection whose exact rounds still match the current tree. */
|
|
3789
|
-
async cleanupTasks(selection) {
|
|
3804
|
+
async cleanupTasks(selection, options = {}) {
|
|
3790
3805
|
const view = cleanup;
|
|
3791
3806
|
const candidates = view.candidates(state.tree ?? null);
|
|
3792
|
-
const prepared = view.request(selection ?? {}, candidates);
|
|
3807
|
+
const prepared = view.request(selection ?? {}, candidates, options);
|
|
3793
3808
|
if (prepared.problems.length > 0) {
|
|
3794
3809
|
notify('error', prepared.problems[0]);
|
|
3795
3810
|
return { ok: false, error: new ApiError('CLEANUP_INVALID', prepared.problems[0]) };
|
|
@@ -3797,6 +3812,9 @@ export function createStore(options = {}) {
|
|
|
3797
3812
|
return await track('cleanup', async () => {
|
|
3798
3813
|
try {
|
|
3799
3814
|
const outcome = await api.cleanupTasks(prepared.body);
|
|
3815
|
+
if (outcome?.cleaned && options?.hostWorkspaces) {
|
|
3816
|
+
await reconcileHostWorkspacesWithCleaned(options.hostWorkspaces, outcome.cleaned);
|
|
3817
|
+
}
|
|
3800
3818
|
const deleted = view.outcome(outcome);
|
|
3801
3819
|
const sentence = view.describe(outcome);
|
|
3802
3820
|
if (sentence === '') throw new ApiError('CLEANUP_RESULT_UNCONFIRMED', '宿主未确认删除结果');
|
|
@@ -3822,6 +3840,34 @@ export function createStore(options = {}) {
|
|
|
3822
3840
|
});
|
|
3823
3841
|
},
|
|
3824
3842
|
|
|
3843
|
+
/** Sweep residual worktrees and dispatched sessions whose task records were already removed. */
|
|
3844
|
+
async cleanupOrphans(options = {}) {
|
|
3845
|
+
if (typeof api.cleanupOrphans !== 'function') {
|
|
3846
|
+
notify('error', '当前宿主未提供残留清理接口。');
|
|
3847
|
+
return { ok: false };
|
|
3848
|
+
}
|
|
3849
|
+
return await track('cleanupOrphans', async () => {
|
|
3850
|
+
try {
|
|
3851
|
+
const outcome = await api.cleanupOrphans({
|
|
3852
|
+
archiveSessions: options?.archiveSessions !== false,
|
|
3853
|
+
removeWorktrees: options?.removeWorktrees !== false,
|
|
3854
|
+
});
|
|
3855
|
+
if (outcome?.cleaned && options?.hostWorkspaces) {
|
|
3856
|
+
await reconcileHostWorkspacesWithCleaned(options.hostWorkspaces, outcome.cleaned);
|
|
3857
|
+
}
|
|
3858
|
+
const sentence = typeof cleanup.describeOrphans === 'function'
|
|
3859
|
+
? cleanup.describeOrphans(outcome)
|
|
3860
|
+
: '已完成残留隔离工作树与已删记录派工对话清理。';
|
|
3861
|
+
notify('success', sentence || '已完成残留清理。');
|
|
3862
|
+
await store.refreshTasks('manual');
|
|
3863
|
+
return { ok: true, outcome };
|
|
3864
|
+
} catch (error) {
|
|
3865
|
+
notify('error', describeError(error));
|
|
3866
|
+
return { ok: false, error };
|
|
3867
|
+
}
|
|
3868
|
+
});
|
|
3869
|
+
},
|
|
3870
|
+
|
|
3825
3871
|
/** Load everything the page needs; the catalog is loaded but not awaited. */
|
|
3826
3872
|
async init() {
|
|
3827
3873
|
await Promise.all([store.refreshStatus(), store.loadSettings(), store.loadNativeProviders(), store.loadTasks()]);
|
|
@@ -3843,3 +3889,77 @@ export function createStore(options = {}) {
|
|
|
3843
3889
|
|
|
3844
3890
|
return store;
|
|
3845
3891
|
}
|
|
3892
|
+
|
|
3893
|
+
function normalizeClientPathKey(pathValue) {
|
|
3894
|
+
if (typeof pathValue !== 'string') return '';
|
|
3895
|
+
const trimmed = pathValue.trim().replace(/[\\/]+$/u, '');
|
|
3896
|
+
return trimmed.toLowerCase();
|
|
3897
|
+
}
|
|
3898
|
+
|
|
3899
|
+
async function reconcileHostWorkspacesWithCleaned(hostWorkspacesOrGetter, cleaned) {
|
|
3900
|
+
if (!cleaned || typeof cleaned !== 'object') return;
|
|
3901
|
+
let wsService = null;
|
|
3902
|
+
try {
|
|
3903
|
+
wsService = typeof hostWorkspacesOrGetter === 'function' ? hostWorkspacesOrGetter() : hostWorkspacesOrGetter;
|
|
3904
|
+
} catch {
|
|
3905
|
+
wsService = null;
|
|
3906
|
+
}
|
|
3907
|
+
if (!wsService || typeof wsService !== 'object') return;
|
|
3908
|
+
|
|
3909
|
+
if (typeof wsService.archiveSession === 'function' && Array.isArray(cleaned.archivedSessionIds)) {
|
|
3910
|
+
for (const sessionId of cleaned.archivedSessionIds) {
|
|
3911
|
+
if (typeof sessionId === 'string' && sessionId !== '') {
|
|
3912
|
+
try {
|
|
3913
|
+
await wsService.archiveSession(sessionId);
|
|
3914
|
+
} catch {
|
|
3915
|
+
// Best-effort client-side session archive.
|
|
3916
|
+
}
|
|
3917
|
+
}
|
|
3918
|
+
}
|
|
3919
|
+
}
|
|
3920
|
+
|
|
3921
|
+
let snapshot = null;
|
|
3922
|
+
try {
|
|
3923
|
+
snapshot = wsService.list?.getSnapshot?.() ?? null;
|
|
3924
|
+
} catch {
|
|
3925
|
+
snapshot = null;
|
|
3926
|
+
}
|
|
3927
|
+
const items = Array.isArray(snapshot?.items) ? snapshot.items : [];
|
|
3928
|
+
const itemById = new Map();
|
|
3929
|
+
for (const item of items) {
|
|
3930
|
+
if (typeof item?.workspaceId === 'string' && item.workspaceId !== '') {
|
|
3931
|
+
itemById.set(item.workspaceId, item);
|
|
3932
|
+
}
|
|
3933
|
+
}
|
|
3934
|
+
|
|
3935
|
+
const removedWorkspaceIds = Array.isArray(cleaned.removedWorkspaceIds) ? cleaned.removedWorkspaceIds : [];
|
|
3936
|
+
const workspaceSet = new Set(removedWorkspaceIds);
|
|
3937
|
+
|
|
3938
|
+
if (Array.isArray(cleaned.removedWorktreePaths) && cleaned.removedWorktreePaths.length > 0 && items.length > 0) {
|
|
3939
|
+
const removedPathKeys = new Set(cleaned.removedWorktreePaths.map(normalizeClientPathKey).filter(Boolean));
|
|
3940
|
+
for (const item of items) {
|
|
3941
|
+
const key = normalizeClientPathKey(item?.path);
|
|
3942
|
+
if (key !== '' && removedPathKeys.has(key) && typeof item.workspaceId === 'string' && !workspaceSet.has(item.workspaceId)) {
|
|
3943
|
+
workspaceSet.add(item.workspaceId);
|
|
3944
|
+
removedWorkspaceIds.push(item.workspaceId);
|
|
3945
|
+
}
|
|
3946
|
+
}
|
|
3947
|
+
cleaned.removedWorkspaceIds = removedWorkspaceIds;
|
|
3948
|
+
}
|
|
3949
|
+
|
|
3950
|
+
if (typeof wsService.delete === 'function' && removedWorkspaceIds.length > 0) {
|
|
3951
|
+
for (const workspaceId of removedWorkspaceIds) {
|
|
3952
|
+
if (typeof workspaceId !== 'string' || workspaceId === '') continue;
|
|
3953
|
+
const item = itemById.get(workspaceId) ?? null;
|
|
3954
|
+
if (item !== null && typeof item.path === 'string' && /[\\/]worktrees[\\/]*$/iu.test(item.path.trim())) {
|
|
3955
|
+
// Never remove the parent TaskBridge worktrees root container workspace itself.
|
|
3956
|
+
continue;
|
|
3957
|
+
}
|
|
3958
|
+
try {
|
|
3959
|
+
await wsService.delete(workspaceId);
|
|
3960
|
+
} catch {
|
|
3961
|
+
// Best-effort client-side workspace removal.
|
|
3962
|
+
}
|
|
3963
|
+
}
|
|
3964
|
+
}
|
|
3965
|
+
}
|
package/src/client/index.jsx
CHANGED
|
@@ -129,9 +129,11 @@ import {
|
|
|
129
129
|
import { registerSessionRowMarker } from './workspaces-browser.jsx';
|
|
130
130
|
import {
|
|
131
131
|
cleanupCandidates,
|
|
132
|
+
cleanupConfirmText,
|
|
132
133
|
cleanupProjection,
|
|
133
134
|
cleanupSelectionSummary,
|
|
134
135
|
cleanupWarningText,
|
|
136
|
+
selectCleanupCandidatesByPreset,
|
|
135
137
|
toggleCleanupSelection,
|
|
136
138
|
withSelectionState,
|
|
137
139
|
} from './task-cleanup.js';
|
|
@@ -1510,12 +1512,15 @@ function PresetsCard({ store, snapshot }) {
|
|
|
1510
1512
|
}
|
|
1511
1513
|
|
|
1512
1514
|
/**
|
|
1513
|
-
* Monitoring controls: the
|
|
1515
|
+
* Monitoring controls: the start-elapsed local self-check, the commander delivery
|
|
1516
|
+
* progress check, and the repeated-failure reminder.
|
|
1514
1517
|
*
|
|
1515
|
-
*
|
|
1516
|
-
*
|
|
1517
|
-
* check
|
|
1518
|
-
*
|
|
1518
|
+
* `selfCheckSeconds` runs one read-only local inspection after execution starts
|
|
1519
|
+
* (default 10 minutes; active work does not postpone it). `attentionSeconds` reports a
|
|
1520
|
+
* run progress check to the commander when nothing new has been returned for that span
|
|
1521
|
+
* (default 40 minutes; internal activity, heartbeats, and self-checks do not reset it).
|
|
1522
|
+
* Neither reminder is a total-runtime cap and neither can cancel, restart, or resubmit
|
|
1523
|
+
* a task.
|
|
1519
1524
|
*
|
|
1520
1525
|
* What this card deliberately does NOT do: it does not submit work, does not read a
|
|
1521
1526
|
* task, does not call a model, and does not create a monitoring process of its own. It
|
|
@@ -1808,7 +1813,7 @@ function ExecutionPanel({ store, snapshot }) {
|
|
|
1808
1813
|
store.editDraft((current) => { current.worker.maxParallelism = value; });
|
|
1809
1814
|
}}
|
|
1810
1815
|
/>
|
|
1811
|
-
<Field label="工作区隔离" htmlFor="dshdg-worker-isolation" hint="
|
|
1816
|
+
<Field label="工作区隔离" htmlFor="dshdg-worker-isolation" hint="默认独立工作树;共享工作区需要你明确选择。两种模式均要求目标目录为已初始化且至少有 1 次 commit 的 Git 仓库根目录。">
|
|
1812
1817
|
<select
|
|
1813
1818
|
id="dshdg-worker-isolation"
|
|
1814
1819
|
value={worker.isolation ?? ISOLATION_MODES[0]}
|
|
@@ -2642,6 +2647,7 @@ function TaskTreeItem({ node, store, snapshot, collapsed, setCollapsed, expanded
|
|
|
2642
2647
|
}
|
|
2643
2648
|
|
|
2644
2649
|
function TaskTreePanel({ store, snapshot, onOpen }) {
|
|
2650
|
+
const nav = useContext(SessionNavigation);
|
|
2645
2651
|
const view = snapshot.tree ?? null;
|
|
2646
2652
|
const [recordView, setRecordView] = useState('recent');
|
|
2647
2653
|
const [collapsed, setCollapsed] = useState(() => new Set());
|
|
@@ -2658,6 +2664,11 @@ function TaskTreePanel({ store, snapshot, onOpen }) {
|
|
|
2658
2664
|
const [cleanupMode, setCleanupMode] = useState(false);
|
|
2659
2665
|
const [cleanupSelection, setCleanupSelection] = useState({});
|
|
2660
2666
|
const [cleanupConfirm, setCleanupConfirm] = useState(false);
|
|
2667
|
+
const [cleanupOptions, setCleanupOptions] = useState({
|
|
2668
|
+
archiveSessions: false,
|
|
2669
|
+
removeWorktrees: false,
|
|
2670
|
+
cleanPlans: false,
|
|
2671
|
+
});
|
|
2661
2672
|
if (view === null) {
|
|
2662
2673
|
return <p className="dshdg-faint" data-dshdg-tree-unavailable="">
|
|
2663
2674
|
{snapshot.tasksError ? '任务树读取失败,下面显示已有记录。' : '当前宿主按列表显示任务。'}
|
|
@@ -2680,14 +2691,28 @@ function TaskTreePanel({ store, snapshot, onOpen }) {
|
|
|
2680
2691
|
: groups.flatMap((group) => group.roots);
|
|
2681
2692
|
const candidates = cleanupCandidates({ roots });
|
|
2682
2693
|
const canCleanup = view.cleanupAvailable === true && (view.counts?.taskChains ?? 0) > 0;
|
|
2694
|
+
const canSweepOrphans = view.cleanupAvailable === true && typeof store?.cleanupOrphans === 'function';
|
|
2683
2695
|
const cleanupActive = cleanupMode && canCleanup;
|
|
2684
2696
|
const cleanupBusy = snapshot.loading?.cleanup === true;
|
|
2697
|
+
const orphanSweepBusy = snapshot.loading?.cleanupOrphans === true;
|
|
2685
2698
|
const summary = cleanupSelectionSummary(cleanupSelection, candidates);
|
|
2686
2699
|
const mayDelete = dateError === null && !cleanupBusy && summary.executable;
|
|
2687
2700
|
function clearSelection() {
|
|
2688
2701
|
setCleanupSelection({});
|
|
2689
2702
|
setCleanupConfirm(false);
|
|
2690
2703
|
}
|
|
2704
|
+
function applyPresetSelection(preset) {
|
|
2705
|
+
setCleanupSelection(selectCleanupCandidatesByPreset(candidates, preset));
|
|
2706
|
+
setCleanupConfirm(false);
|
|
2707
|
+
}
|
|
2708
|
+
function toggleCleanupOption(key) {
|
|
2709
|
+
setCleanupOptions((prev) => ({ ...prev, [key]: !prev[key] }));
|
|
2710
|
+
setCleanupConfirm(false);
|
|
2711
|
+
}
|
|
2712
|
+
async function runOrphanSweep() {
|
|
2713
|
+
if (orphanSweepBusy || cleanupBusy) return;
|
|
2714
|
+
await store.cleanupOrphans({ hostWorkspaces: nav?.workspaces });
|
|
2715
|
+
}
|
|
2691
2716
|
const updateFilter = (setter) => (event) => {
|
|
2692
2717
|
setter(event.target.value);
|
|
2693
2718
|
clearSelection();
|
|
@@ -2708,6 +2733,7 @@ function TaskTreePanel({ store, snapshot, onOpen }) {
|
|
|
2708
2733
|
function leaveCleanup() {
|
|
2709
2734
|
setCleanupMode(false);
|
|
2710
2735
|
clearSelection();
|
|
2736
|
+
setCleanupOptions({ archiveSessions: false, removeWorktrees: false, cleanPlans: false });
|
|
2711
2737
|
}
|
|
2712
2738
|
function onToggleChain(candidate) {
|
|
2713
2739
|
setCleanupSelection((old) => toggleCleanupSelection(old, withSelectionState(candidate, old[candidate.chainId])));
|
|
@@ -2715,7 +2741,10 @@ function TaskTreePanel({ store, snapshot, onOpen }) {
|
|
|
2715
2741
|
}
|
|
2716
2742
|
async function confirmCleanup() {
|
|
2717
2743
|
if (!mayDelete) return;
|
|
2718
|
-
const result = await store.cleanupTasks(cleanupSelection
|
|
2744
|
+
const result = await store.cleanupTasks(cleanupSelection, {
|
|
2745
|
+
...cleanupOptions,
|
|
2746
|
+
hostWorkspaces: nav?.workspaces,
|
|
2747
|
+
});
|
|
2719
2748
|
if (result.ok) leaveCleanup();
|
|
2720
2749
|
setCleanupConfirm(false);
|
|
2721
2750
|
}
|
|
@@ -2772,6 +2801,17 @@ function TaskTreePanel({ store, snapshot, onOpen }) {
|
|
|
2772
2801
|
项目树
|
|
2773
2802
|
</button>
|
|
2774
2803
|
</div>
|
|
2804
|
+
{canSweepOrphans ? (
|
|
2805
|
+
<button
|
|
2806
|
+
type="button"
|
|
2807
|
+
data-dshdg-cleanup-orphans=""
|
|
2808
|
+
disabled={orphanSweepBusy || cleanupBusy}
|
|
2809
|
+
title="扫描并清理任务记录已删除后残留的隔离工作树目录、DSH 临时工作区及已删记录对应的派工对话(绝不触碰共享工作区与源码)"
|
|
2810
|
+
onClick={() => { void runOrphanSweep(); }}
|
|
2811
|
+
>
|
|
2812
|
+
{orphanSweepBusy ? '正在清理残留…' : '清理残留工作区与对话'}
|
|
2813
|
+
</button>
|
|
2814
|
+
) : null}
|
|
2775
2815
|
{canCleanup ? (
|
|
2776
2816
|
<button
|
|
2777
2817
|
type="button"
|
|
@@ -2830,6 +2870,65 @@ function TaskTreePanel({ store, snapshot, onOpen }) {
|
|
|
2830
2870
|
<p className="dshdg-hint" data-dshdg-cleanup-counts="">
|
|
2831
2871
|
{`已选 ${summary.chains} 条执行链 / 共 ${summary.rounds} 轮`}
|
|
2832
2872
|
</p>
|
|
2873
|
+
<div className="dshdg-row" data-dshdg-cleanup-presets="">
|
|
2874
|
+
<span className="dshdg-hint">快捷选择(当前筛选视图):</span>
|
|
2875
|
+
<button
|
|
2876
|
+
type="button"
|
|
2877
|
+
data-dshdg-cleanup-preset="all"
|
|
2878
|
+
disabled={cleanupBusy}
|
|
2879
|
+
onClick={() => applyPresetSelection('all')}
|
|
2880
|
+
>
|
|
2881
|
+
全选可清理
|
|
2882
|
+
</button>
|
|
2883
|
+
<button
|
|
2884
|
+
type="button"
|
|
2885
|
+
data-dshdg-cleanup-preset="accepted"
|
|
2886
|
+
disabled={cleanupBusy}
|
|
2887
|
+
onClick={() => applyPresetSelection('accepted')}
|
|
2888
|
+
>
|
|
2889
|
+
全选已审查通过
|
|
2890
|
+
</button>
|
|
2891
|
+
<button
|
|
2892
|
+
type="button"
|
|
2893
|
+
data-dshdg-cleanup-preset="failed-cancelled"
|
|
2894
|
+
disabled={cleanupBusy}
|
|
2895
|
+
onClick={() => applyPresetSelection('failed-cancelled')}
|
|
2896
|
+
>
|
|
2897
|
+
全选已失败/已取消
|
|
2898
|
+
</button>
|
|
2899
|
+
</div>
|
|
2900
|
+
<div className="dshdg-cleanup-options" data-dshdg-cleanup-options="">
|
|
2901
|
+
<label className="dshdg-check">
|
|
2902
|
+
<input
|
|
2903
|
+
type="checkbox"
|
|
2904
|
+
data-dshdg-cleanup-opt="archiveSessions"
|
|
2905
|
+
checked={cleanupOptions.archiveSessions}
|
|
2906
|
+
disabled={cleanupBusy}
|
|
2907
|
+
onChange={() => toggleCleanupOption('archiveSessions')}
|
|
2908
|
+
/>
|
|
2909
|
+
<span>同时归档对应的 DSH 派工对话(共享与隔离模式均适用,不影响你自己的普通对话)</span>
|
|
2910
|
+
</label>
|
|
2911
|
+
<label className="dshdg-check">
|
|
2912
|
+
<input
|
|
2913
|
+
type="checkbox"
|
|
2914
|
+
data-dshdg-cleanup-opt="removeWorktrees"
|
|
2915
|
+
checked={cleanupOptions.removeWorktrees}
|
|
2916
|
+
disabled={cleanupBusy}
|
|
2917
|
+
onChange={() => toggleCleanupOption('removeWorktrees')}
|
|
2918
|
+
/>
|
|
2919
|
+
<span>同时删除隔离任务的工作树目录与 DSH 临时工作区(仅作用于独立工作树,绝不删除共享工作区与源文件)</span>
|
|
2920
|
+
</label>
|
|
2921
|
+
<label className="dshdg-check">
|
|
2922
|
+
<input
|
|
2923
|
+
type="checkbox"
|
|
2924
|
+
data-dshdg-cleanup-opt="cleanPlans"
|
|
2925
|
+
checked={cleanupOptions.cleanPlans}
|
|
2926
|
+
disabled={cleanupBusy}
|
|
2927
|
+
onChange={() => toggleCleanupOption('cleanPlans')}
|
|
2928
|
+
/>
|
|
2929
|
+
<span>同时清理已无关联任务的空规划节点</span>
|
|
2930
|
+
</label>
|
|
2931
|
+
</div>
|
|
2833
2932
|
{cleanupConfirm ? null : <p className="dshdg-warn">{cleanupWarningText()}</p>}
|
|
2834
2933
|
{Object.keys(cleanupSelection).length === 0 ? null : summary.problems.map((problem) => (
|
|
2835
2934
|
<p className="dshdg-warn" role="alert" key={problem} data-dshdg-cleanup-problem="">{problem}</p>
|
|
@@ -2837,7 +2936,7 @@ function TaskTreePanel({ store, snapshot, onOpen }) {
|
|
|
2837
2936
|
{cleanupConfirm ? (
|
|
2838
2937
|
<div className="dshdg-row" data-dshdg-cleanup-confirm-dialog="" role="alertdialog" aria-label="确认永久删除记录">
|
|
2839
2938
|
<span>
|
|
2840
|
-
{
|
|
2939
|
+
{cleanupConfirmText(summary, cleanupOptions)}
|
|
2841
2940
|
</span>
|
|
2842
2941
|
<button
|
|
2843
2942
|
type="button"
|
|
@@ -3678,9 +3777,11 @@ export {
|
|
|
3678
3777
|
};
|
|
3679
3778
|
|
|
3680
3779
|
export {
|
|
3780
|
+
CLEANUP_PRESETS,
|
|
3681
3781
|
MAX_CLEANUP_CHAINS,
|
|
3682
3782
|
cleanupBlockerLabel,
|
|
3683
3783
|
cleanupCandidates,
|
|
3784
|
+
cleanupConfirmText,
|
|
3684
3785
|
cleanupOutcome,
|
|
3685
3786
|
cleanupProjection,
|
|
3686
3787
|
cleanupRequest,
|
|
@@ -3688,7 +3789,9 @@ export {
|
|
|
3688
3789
|
cleanupSelectionSummary,
|
|
3689
3790
|
cleanupWarningText,
|
|
3690
3791
|
describeCleanupOutcome,
|
|
3792
|
+
describeOrphanCleanupOutcome,
|
|
3691
3793
|
pruneCleanupSelection,
|
|
3794
|
+
selectCleanupCandidatesByPreset,
|
|
3692
3795
|
toggleCleanupSelection,
|
|
3693
3796
|
withSelectionState,
|
|
3694
3797
|
} from './task-cleanup.js';
|