dsh-taskbridge 1.5.4 → 1.7.0
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 +80 -59
- package/README.md +51 -50
- package/THIRD_PARTY_NOTICES.txt +23 -0
- package/bin/dsh-delegate-mcp.d.ts +1 -0
- package/bin/dsh-delegate-mcp.js +1 -0
- package/codex/dsh-taskbridge.toml +148 -71
- package/docs/INTRODUCTION.md +44 -22
- package/docs/INTRODUCTION.zh.md +32 -26
- package/docs/codex-integration.md +99 -19
- package/docs/contracts-stage-b.md +4 -4
- package/docs/conversation-placement.md +25 -7
- package/docs/plugin-market.md +1 -1
- package/docs/releases/1.6.0.zh.md +11 -0
- package/docs/releases/1.7.0.zh.md +11 -0
- package/docs/runtime-compatibility.md +10 -11
- package/docs/silent-wait.md +69 -31
- package/docs/taskbridge-upgrade.md +1 -1
- package/docs/worker-permissions.md +11 -21
- package/docs/workspace-grouping.md +126 -0
- package/lib/client.d.ts +581 -0
- package/lib/client.js +332 -3461
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +7 -19
- package/src/client/api.js +895 -90
- package/src/client/index.jsx +1363 -296
- package/src/client/sidebar.jsx +862 -0
- package/src/client/styles.js +340 -0
- package/src/client/task-cleanup.js +304 -0
- package/src/client/task-records-table.jsx +217 -0
- package/src/client/task-view.js +307 -0
- package/src/client/workspace-groups.js +482 -0
- package/src/client/workspaces-browser.jsx +770 -0
- package/src/codex/agent-ownership.js +270 -0
- package/src/codex/installer.js +528 -35
- package/src/codex/seam.js +5 -0
- package/src/config/defaults.js +63 -17
- package/src/config/settings.js +60 -62
- package/src/config/validate.js +126 -71
- package/src/http/execution-plane.js +200 -1
- package/src/http/respond.js +26 -2
- package/src/http/user-plane.js +566 -2
- package/src/index.d.ts +55 -0
- package/src/index.js +58 -42
- package/src/jobs/activity.js +968 -78
- package/src/jobs/engine.js +1010 -230
- package/src/jobs/history.js +224 -12
- package/src/jobs/plan-store.js +1020 -0
- package/src/jobs/record-cleanup.js +196 -0
- package/src/jobs/task-display.js +73 -0
- package/src/jobs/task-tree.js +786 -0
- package/src/jobs/title.js +129 -12
- package/src/mcp/server.js +206 -10
- package/src/mcp/wait.js +64 -5
- package/src/runtime/agent-runner.js +101 -15
- package/src/runtime/worker-prompt.js +53 -0
- package/src/workspace/locks.js +288 -167
- package/docs/assets/taskbridge-workflow.en.png +0 -0
- package/docs/assets/taskbridge-workflow.zh.png +0 -0
- package/docs/releases/1.4.0-token-benchmark.zh.md +0 -40
- package/docs/releases/1.4.0.zh.md +0 -54
- package/docs/releases/1.4.1.zh.md +0 -59
- package/docs/releases/1.4.2.zh.md +0 -23
- package/docs/releases/1.5.0-token-benchmark.zh.md +0 -73
- package/docs/releases/1.5.0.zh.md +0 -51
- package/docs/releases/1.5.1.zh.md +0 -70
- package/docs/releases/1.5.2.zh.md +0 -30
- package/docs/releases/1.5.3-test.1.zh.md +0 -28
- package/docs/releases/1.5.3-test.2.zh.md +0 -24
- package/docs/releases/1.5.3.zh.md +0 -33
- package/docs/releases/1.5.4.zh.md +0 -25
- package/src/review/preset.js +0 -868
- package/src/review/prompts.js +0 -145
- package/src/review/reviewer.js +0 -933
package/src/client/index.jsx
CHANGED
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
// beyond `@deepseek-ai/*` platform modules, which is why the native loader can
|
|
48
48
|
// resolve every external against its frozen platform table.
|
|
49
49
|
|
|
50
|
-
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';
|
|
50
|
+
import { createContext, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';
|
|
51
51
|
|
|
52
52
|
import {
|
|
53
53
|
CONNECTIVITY_LAYERS,
|
|
@@ -66,6 +66,9 @@ import {
|
|
|
66
66
|
REVIEW_VERDICT_LABELS,
|
|
67
67
|
SUPPORTED_PROTOCOLS,
|
|
68
68
|
TASK_STATES,
|
|
69
|
+
TREE_ORPHAN_LABELS,
|
|
70
|
+
TREE_STATUS_LABELS,
|
|
71
|
+
TREE_STATUS_TONES,
|
|
69
72
|
boundedText,
|
|
70
73
|
changedFiles,
|
|
71
74
|
clone,
|
|
@@ -83,19 +86,24 @@ import {
|
|
|
83
86
|
grantState,
|
|
84
87
|
isAwaitingPermission,
|
|
85
88
|
isCancellable,
|
|
89
|
+
executionOf,
|
|
90
|
+
AGENT_TEAMS_ORIGIN_LABELS,
|
|
86
91
|
hasLiveTasks,
|
|
87
92
|
formatDuration,
|
|
88
93
|
hostReviewLine,
|
|
89
94
|
RECORD_REFRESH_INTERVAL_MS,
|
|
90
95
|
recordRefreshPlan,
|
|
96
|
+
startRecordsReadLoop,
|
|
91
97
|
reviewNotePreview,
|
|
92
98
|
hasChangingRecords,
|
|
93
99
|
isLiveTask,
|
|
94
100
|
minutesToSeconds,
|
|
95
101
|
monitoringDraftOf,
|
|
96
102
|
monitoringOf,
|
|
103
|
+
monitoringText,
|
|
97
104
|
pendingPermission,
|
|
98
105
|
permissionSummary,
|
|
106
|
+
planCreateRequest,
|
|
99
107
|
precheckDraft,
|
|
100
108
|
precheckMonitoring,
|
|
101
109
|
previewEffective,
|
|
@@ -110,6 +118,21 @@ import {
|
|
|
110
118
|
WAIT_REASON_LABELS,
|
|
111
119
|
} from './api.js';
|
|
112
120
|
import { injectStyles } from './styles.js';
|
|
121
|
+
import {
|
|
122
|
+
locateSession, resolveService, resolveUiWorkspace, resolveWorkspaces, taskSessionId,
|
|
123
|
+
} from './sidebar.jsx';
|
|
124
|
+
import { registerSessionRowMarker } from './workspaces-browser.jsx';
|
|
125
|
+
import {
|
|
126
|
+
cleanupCandidates,
|
|
127
|
+
cleanupProjection,
|
|
128
|
+
cleanupSelectionSummary,
|
|
129
|
+
cleanupWarningText,
|
|
130
|
+
toggleCleanupSelection,
|
|
131
|
+
withSelectionState,
|
|
132
|
+
} from './task-cleanup.js';
|
|
133
|
+
import { projectTaskView } from './task-view.js';
|
|
134
|
+
import { TaskRecordsTable } from './task-records-table.jsx';
|
|
135
|
+
import { registerWorkspacesBrowser } from './workspaces-browser.jsx';
|
|
113
136
|
|
|
114
137
|
/** Plugins-manager config slot this page occupies. */
|
|
115
138
|
export const PLUGIN_CONFIG_SLOT = 'plugins.bundle.config';
|
|
@@ -124,6 +147,8 @@ export const PLUGIN_BUNDLE_KEY = 'dsh-taskbridge';
|
|
|
124
147
|
/** Required client services: slot registration only. */
|
|
125
148
|
export const inject = ['slots'];
|
|
126
149
|
|
|
150
|
+
const SessionNavigation = createContext(null);
|
|
151
|
+
|
|
127
152
|
/**
|
|
128
153
|
* Register the bundle configuration page on a client context.
|
|
129
154
|
*
|
|
@@ -135,8 +160,8 @@ export const inject = ['slots'];
|
|
|
135
160
|
* @returns {Function} disposer releasing the registration.
|
|
136
161
|
*/
|
|
137
162
|
export function registerBundleConfiguration(ctx, options) {
|
|
138
|
-
const store = options
|
|
139
|
-
const injectFace = () => ({ store });
|
|
163
|
+
const { store, uiWorkspace, workspaces } = options;
|
|
164
|
+
const injectFace = () => ({ store, uiWorkspace, workspaces });
|
|
140
165
|
return ctx.slots.inject(PLUGIN_CONFIG_SLOT, () => ctx.slots.register({
|
|
141
166
|
name: PLUGIN_CONFIG_SLOT,
|
|
142
167
|
key: PLUGIN_BUNDLE_KEY,
|
|
@@ -150,9 +175,55 @@ export function registerBundleConfiguration(ctx, options) {
|
|
|
150
175
|
*/
|
|
151
176
|
export function apply(ctx) {
|
|
152
177
|
ctx.effect(() => injectStyles(globalThis.document), 'dsh-delegate: settings styles');
|
|
153
|
-
const store = createStore({ api: createApi() });
|
|
178
|
+
const store = createStore({ api: createApi(), cleanup: cleanupProjection() });
|
|
154
179
|
ctx.effect(() => () => store.dispose(), 'dsh-delegate: settings store');
|
|
155
|
-
|
|
180
|
+
const navigation = {
|
|
181
|
+
store,
|
|
182
|
+
uiWorkspace: () => resolveUiWorkspace(ctx),
|
|
183
|
+
workspaces: () => resolveWorkspaces(ctx),
|
|
184
|
+
};
|
|
185
|
+
ctx.effect(() => registerBundleConfiguration(ctx, navigation), 'dsh-delegate: bundle configuration');
|
|
186
|
+
// NO standalone sidebar row for task records.
|
|
187
|
+
//
|
|
188
|
+
// `registerTasksNavigation` registers TWO entries at once — the content panel on `main` AND the
|
|
189
|
+
// row on `sidebar.panellist` — so the row cannot be removed while the panel is kept by any
|
|
190
|
+
// smaller change. Both are therefore not mounted: the operator reaches the task records through
|
|
191
|
+
// the plugin's own settings page (`plugins.bundle.config` → 「任务记录」tab), which is the
|
|
192
|
+
// single, already-shipped entry point, and the sidebar keeps ONLY the host's native workspace
|
|
193
|
+
// tree (工作区 → TaskBridge → 隔离任务工作区 → 对话). The module stays exported and tested, so a
|
|
194
|
+
// later host that wants the row back needs one line, not a rewrite.
|
|
195
|
+
// The TaskBridge sidebar integration. The shell's workspace region stays the HOST's: this
|
|
196
|
+
// registers only the published per-row child slot (`sidebar.workspaces.session.row.action`), so
|
|
197
|
+
// every native row, name, order, search box, menu and action is exactly as shipped, and a
|
|
198
|
+
// dispatched conversation gains one quiet marker inside its own native row.
|
|
199
|
+
ctx.effect(() => registerSessionRowMarker(ctx, { store }), 'dsh-delegate: dispatched session marker');
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* The host's own `sidebar.workspaces` entry, when this build can reach it.
|
|
204
|
+
*
|
|
205
|
+
* The shell keeps the shipped registration in its slot ledger, and a lower-priority entry can
|
|
206
|
+
* render that component itself instead of re-implementing (or replacing) it. What is reachable
|
|
207
|
+
* depends on the host: the shipped entry exposes no component through a published contract, so
|
|
208
|
+
* this returns `null` unless a host offers one. `null` is the honest answer — the section is then
|
|
209
|
+
* drawn alone, and the host browser is not claimed.
|
|
210
|
+
* @param {object} ctx - client context.
|
|
211
|
+
* @returns {Function | null} the shipped component, or null.
|
|
212
|
+
*/
|
|
213
|
+
export function resolveNativeWorkspaceEntry(ctx) {
|
|
214
|
+
const get = ctx !== null && typeof ctx === 'object' ? ctx.get : null;
|
|
215
|
+
if (typeof get !== 'function') return null;
|
|
216
|
+
for (const name of ['uiWorkspace', 'workspaces']) {
|
|
217
|
+
let service = null;
|
|
218
|
+
try {
|
|
219
|
+
service = get.call(ctx, name);
|
|
220
|
+
} catch {
|
|
221
|
+
service = null;
|
|
222
|
+
}
|
|
223
|
+
const entry = service?.nativeEntry ?? service?.WorkspaceBrowser ?? null;
|
|
224
|
+
if (typeof entry === 'function') return entry;
|
|
225
|
+
}
|
|
226
|
+
return null;
|
|
156
227
|
}
|
|
157
228
|
|
|
158
229
|
// ---------------------------------------------------------------------------
|
|
@@ -658,9 +729,7 @@ function ProviderEditor({ provider, store, snapshot, index }) {
|
|
|
658
729
|
const target = draft.providers.find((entry) => entry.id === providerId);
|
|
659
730
|
if (target === undefined) return;
|
|
660
731
|
target.id = nextId;
|
|
661
|
-
|
|
662
|
-
if (block?.providerId === providerId) block.providerId = nextId;
|
|
663
|
-
}
|
|
732
|
+
if (draft.worker?.providerId === providerId) draft.worker.providerId = nextId;
|
|
664
733
|
});
|
|
665
734
|
}}
|
|
666
735
|
/>
|
|
@@ -835,13 +904,10 @@ function ProviderEditor({ provider, store, snapshot, index }) {
|
|
|
835
904
|
// A selection pointing at the removed model would be
|
|
836
905
|
// unroutable; clear it here so the operator sees the
|
|
837
906
|
// consequence instead of saving an invalid pair.
|
|
838
|
-
if (removed !== undefined
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
block.reasoningEffort = null;
|
|
843
|
-
}
|
|
844
|
-
}
|
|
907
|
+
if (removed !== undefined && draft.worker?.providerId === providerId
|
|
908
|
+
&& draft.worker.model === removed.id) {
|
|
909
|
+
draft.worker.model = null;
|
|
910
|
+
draft.worker.reasoningEffort = null;
|
|
845
911
|
}
|
|
846
912
|
});
|
|
847
913
|
}}
|
|
@@ -948,9 +1014,9 @@ function ProvidersPanel({ store, snapshot }) {
|
|
|
948
1014
|
|
|
949
1015
|
function isUsed(id) {
|
|
950
1016
|
const draft = snapshot.draft ?? {};
|
|
951
|
-
const selections = [draft.worker,
|
|
1017
|
+
const selections = [draft.worker, ...(draft.presets ?? []).map((preset) => preset.worker)];
|
|
952
1018
|
for (const block of Object.values(draft.projectOverrides ?? {})) {
|
|
953
|
-
selections.push(block?.worker
|
|
1019
|
+
selections.push(block?.worker);
|
|
954
1020
|
}
|
|
955
1021
|
return selections.some((selection) => selection?.providerId === id);
|
|
956
1022
|
}
|
|
@@ -1116,7 +1182,6 @@ function LegacyProvidersPanel({ store, snapshot }) {
|
|
|
1116
1182
|
*/
|
|
1117
1183
|
function EffectiveSummary({ label, effective, note }) {
|
|
1118
1184
|
const worker = effective?.worker ?? {};
|
|
1119
|
-
const review = effective?.review ?? {};
|
|
1120
1185
|
return (
|
|
1121
1186
|
<div className="dshdg-card">
|
|
1122
1187
|
<h4>{label}</h4>
|
|
@@ -1127,25 +1192,26 @@ function EffectiveSummary({ label, effective, note }) {
|
|
|
1127
1192
|
<dd className="dshdg-mono">{worker.model ?? '(未配置)'}</dd>
|
|
1128
1193
|
<dt>执行推理强度</dt>
|
|
1129
1194
|
<dd className="dshdg-mono">{worker.reasoningEffort ?? '(不指定)'}</dd>
|
|
1130
|
-
<dt
|
|
1131
|
-
<dd>
|
|
1195
|
+
<dt>执行时长</dt>
|
|
1196
|
+
<dd>
|
|
1197
|
+
{effective?.worker?.executionTimeoutSeconds === null || effective?.worker?.executionTimeoutSeconds === undefined
|
|
1198
|
+
? '不设上限(只由你主动取消)'
|
|
1199
|
+
: `本任务显式上限 ${formatDuration(effective.worker.executionTimeoutSeconds * 1000)}`}
|
|
1200
|
+
</dd>
|
|
1132
1201
|
<dt>最大并发</dt>
|
|
1133
1202
|
<dd>{worker.maxParallelism ?? '—'}</dd>
|
|
1134
1203
|
<dt>工作区隔离</dt>
|
|
1135
1204
|
<dd>{ISOLATION_LABELS[worker.isolation] ?? worker.isolation ?? '—'}</dd>
|
|
1136
1205
|
<dt>对话</dt>
|
|
1137
1206
|
<dd>{CONVERSATION_POLICY_LABEL}</dd>
|
|
1138
|
-
<dt>附加审查</dt>
|
|
1139
|
-
<dd>
|
|
1140
|
-
{review.enabled === true
|
|
1141
|
-
? `开启 · ${review.providerId ?? '(未配置)'} / ${review.model ?? '(未配置)'} / ${review.reasoningEffort ?? '不指定'}`
|
|
1142
|
-
: '关闭'}
|
|
1143
|
-
</dd>
|
|
1144
1207
|
<dt>静默监控</dt>
|
|
1145
1208
|
<dd>
|
|
1146
1209
|
{effective?.monitoring === null || effective?.monitoring === undefined
|
|
1147
1210
|
? '未采集到'
|
|
1148
|
-
:
|
|
1211
|
+
: [
|
|
1212
|
+
`自检 ${monitoringText(effective.monitoring.selfCheckSeconds)}`,
|
|
1213
|
+
`运行进度检查 ${monitoringText(effective.monitoring.attentionSeconds)}`,
|
|
1214
|
+
].join(' · ')}
|
|
1149
1215
|
</dd>
|
|
1150
1216
|
</dl>
|
|
1151
1217
|
{note === undefined ? null : <p className="dshdg-hint">{note}</p>}
|
|
@@ -1178,7 +1244,7 @@ function PresetsCard({ store, snapshot }) {
|
|
|
1178
1244
|
<div className="dshdg-card">
|
|
1179
1245
|
<h4>预设、导出与项目覆盖</h4>
|
|
1180
1246
|
<p className="dshdg-hint">
|
|
1181
|
-
|
|
1247
|
+
预设保存执行设置,导出的配置不含密钥。
|
|
1182
1248
|
正在运行的任务保留它自己的生效快照,之后的修改不会改写历史。
|
|
1183
1249
|
</p>
|
|
1184
1250
|
|
|
@@ -1204,18 +1270,15 @@ function PresetsCard({ store, snapshot }) {
|
|
|
1204
1270
|
store.editDraft((current) => {
|
|
1205
1271
|
const existing = current.presets.find((entry) => entry.id === presetId);
|
|
1206
1272
|
const snapshotWorker = clone(current.worker);
|
|
1207
|
-
const snapshotReview = current.review?.enabled === true ? clone(current.review) : null;
|
|
1208
1273
|
if (existing === undefined) {
|
|
1209
1274
|
current.presets.push({
|
|
1210
1275
|
id: presetId,
|
|
1211
1276
|
name: presetName === '' ? presetId : presetName,
|
|
1212
1277
|
worker: snapshotWorker,
|
|
1213
|
-
...(snapshotReview === null ? {} : { review: snapshotReview }),
|
|
1214
1278
|
});
|
|
1215
1279
|
} else {
|
|
1216
1280
|
existing.name = presetName === '' ? existing.name : presetName;
|
|
1217
1281
|
existing.worker = snapshotWorker;
|
|
1218
|
-
existing.review = snapshotReview;
|
|
1219
1282
|
}
|
|
1220
1283
|
});
|
|
1221
1284
|
setPresetId('');
|
|
@@ -1239,7 +1302,6 @@ function PresetsCard({ store, snapshot }) {
|
|
|
1239
1302
|
onClick={() => {
|
|
1240
1303
|
store.editDraft((current) => {
|
|
1241
1304
|
if (preset.worker !== null && preset.worker !== undefined) current.worker = { ...preset.worker };
|
|
1242
|
-
if (preset.review !== null && preset.review !== undefined) current.review = { ...preset.review };
|
|
1243
1305
|
});
|
|
1244
1306
|
}}
|
|
1245
1307
|
>
|
|
@@ -1318,7 +1380,6 @@ function PresetsCard({ store, snapshot }) {
|
|
|
1318
1380
|
store.editDraft((current) => {
|
|
1319
1381
|
current.providers = next.providers;
|
|
1320
1382
|
current.worker = next.worker;
|
|
1321
|
-
current.review = next.review;
|
|
1322
1383
|
current.authorization = next.authorization;
|
|
1323
1384
|
current.projectOverrides = next.projectOverrides;
|
|
1324
1385
|
current.presets = next.presets;
|
|
@@ -1389,9 +1450,9 @@ function PresetsCard({ store, snapshot }) {
|
|
|
1389
1450
|
/>
|
|
1390
1451
|
</Field>
|
|
1391
1452
|
<Field
|
|
1392
|
-
label=
|
|
1453
|
+
label="执行覆盖内容(JSON)"
|
|
1393
1454
|
htmlFor="dshdg-override-json"
|
|
1394
|
-
hint={'例如 {"worker":{"model":"deepseek-chat","reasoningEffort":"high"}
|
|
1455
|
+
hint={'例如 {"worker":{"model":"deepseek-chat","reasoningEffort":"high"}}'}
|
|
1395
1456
|
>
|
|
1396
1457
|
<textarea
|
|
1397
1458
|
id="dshdg-override-json"
|
|
@@ -1412,7 +1473,7 @@ function PresetsCard({ store, snapshot }) {
|
|
|
1412
1473
|
setOverrideError(`无法解析:${String(error?.message ?? error).slice(0, 160)}`);
|
|
1413
1474
|
return;
|
|
1414
1475
|
}
|
|
1415
|
-
const unknown = Object.keys(parsed).filter((key) => key !== 'worker'
|
|
1476
|
+
const unknown = Object.keys(parsed).filter((key) => key !== 'worker');
|
|
1416
1477
|
if (unknown.length > 0) {
|
|
1417
1478
|
setOverrideError(`不支持的字段:${unknown.join('、')}`);
|
|
1418
1479
|
return;
|
|
@@ -1444,18 +1505,24 @@ function PresetsCard({ store, snapshot }) {
|
|
|
1444
1505
|
}
|
|
1445
1506
|
|
|
1446
1507
|
/**
|
|
1447
|
-
*
|
|
1508
|
+
* Monitoring controls: the two no-progress reminders and the repeated-failure reminder.
|
|
1509
|
+
*
|
|
1510
|
+
* There is exactly ONE time base — consecutive time without real progress — and TWO
|
|
1511
|
+
* duration controls on it: the local self-check (default 10 minutes) and the run progress
|
|
1512
|
+
* check reported to the dispatcher (default 40 minutes). A task that keeps working never
|
|
1513
|
+
* reaches either, whatever its total runtime; a run's length is never itself a reminder.
|
|
1448
1514
|
*
|
|
1449
1515
|
* What this card deliberately does NOT do: it does not submit work, does not read a
|
|
1450
|
-
* task, does not call a model, and does not create a monitoring process of its own.
|
|
1451
|
-
*
|
|
1452
|
-
*
|
|
1453
|
-
*
|
|
1516
|
+
* task, does not call a model, and does not create a monitoring process of its own. It
|
|
1517
|
+
* edits numbers that ride the ordinary settings draft, and everything it says about the
|
|
1518
|
+
* behaviour is a statement about the engine, not a control here. Neither reminder can
|
|
1519
|
+
* cancel, restart or resubmit a task.
|
|
1454
1520
|
*
|
|
1455
1521
|
* Units: the operator thinks in minutes, the document stores whole seconds. Each
|
|
1456
|
-
* field converts on the way in and out (`minutesToSeconds` / `secondsToMinutes`),
|
|
1457
|
-
* stored value of
|
|
1458
|
-
* rounded into a different setting.
|
|
1522
|
+
* duration field converts on the way in and out (`minutesToSeconds` / `secondsToMinutes`),
|
|
1523
|
+
* so a stored value of 600 s shows as 10 and a value of 90 s shows as 1.5 rather than
|
|
1524
|
+
* being rounded into a different setting. `0` is a real, expressible decision — "this
|
|
1525
|
+
* reminder is off" — and is both displayed and written as `0`.
|
|
1459
1526
|
* @param {object} props - `store`, `snapshot`.
|
|
1460
1527
|
* @returns {object} the monitoring card.
|
|
1461
1528
|
*/
|
|
@@ -1472,11 +1539,10 @@ function MonitoringCard({ store, snapshot }) {
|
|
|
1472
1539
|
|| raw.repeatFailureThreshold !== saved.repeatFailureThreshold;
|
|
1473
1540
|
|
|
1474
1541
|
/**
|
|
1475
|
-
* Write one field, converting minutes back to the stored unit.
|
|
1476
|
-
*
|
|
1477
|
-
*
|
|
1478
|
-
*
|
|
1479
|
-
* back to their defaults on every keystroke.
|
|
1542
|
+
* Write one field, converting minutes back to the stored unit. The block is spread
|
|
1543
|
+
* from the RAW draft, not from `monitoringOf`: normalizing here would rewrite the
|
|
1544
|
+
* operator's other half-typed fields (for example a cleared count) back to their
|
|
1545
|
+
* defaults on every keystroke.
|
|
1480
1546
|
* @param {'selfCheckSeconds' | 'attentionSeconds'} field - target field.
|
|
1481
1547
|
* @param {unknown} rawMinutes - operator input, in minutes.
|
|
1482
1548
|
* @returns {void}
|
|
@@ -1502,52 +1568,73 @@ function MonitoringCard({ store, snapshot }) {
|
|
|
1502
1568
|
});
|
|
1503
1569
|
};
|
|
1504
1570
|
|
|
1571
|
+
/**
|
|
1572
|
+
* One duration control, in minutes, with `0` meaning "off".
|
|
1573
|
+
*
|
|
1574
|
+
* Extracted so the two durations cannot drift apart in units, bounds or wording.
|
|
1575
|
+
* @param {object} props - `id`, `label`, `field`, `value`, `min`, `max`, `hint`.
|
|
1576
|
+
* @returns {object} the field.
|
|
1577
|
+
*/
|
|
1578
|
+
const DurationField = ({ id, label, field, value, min, max, hint }) => {
|
|
1579
|
+
const minutes = Number.isFinite(secondsToMinutes(value)) ? secondsToMinutes(value) : '';
|
|
1580
|
+
return (
|
|
1581
|
+
<Field
|
|
1582
|
+
label={label}
|
|
1583
|
+
htmlFor={id}
|
|
1584
|
+
hint={`${min / 60}–${max / 60} 分钟,填 0 表示关闭;存成整秒(当前 ${value === '' ? '未填' : (Number(value) === 0 ? '已关闭' : `${value} 秒`) })${hint === undefined ? '' : `;${hint}`}`}
|
|
1585
|
+
>
|
|
1586
|
+
<input
|
|
1587
|
+
id={id}
|
|
1588
|
+
type="number"
|
|
1589
|
+
inputMode="decimal"
|
|
1590
|
+
min={0}
|
|
1591
|
+
max={max / 60}
|
|
1592
|
+
step={0.5}
|
|
1593
|
+
value={String(minutes)}
|
|
1594
|
+
onChange={(event) => {
|
|
1595
|
+
const next = event.target.value;
|
|
1596
|
+
// A blank field stays blank (the precheck reports it) instead of becoming
|
|
1597
|
+
// the default or an accidental zero.
|
|
1598
|
+
edit(field, next === '' ? '' : next);
|
|
1599
|
+
}}
|
|
1600
|
+
/>
|
|
1601
|
+
</Field>
|
|
1602
|
+
);
|
|
1603
|
+
};
|
|
1604
|
+
|
|
1505
1605
|
return (
|
|
1506
1606
|
<div className="dshdg-card" data-dshdg-monitoring="">
|
|
1507
|
-
<h4
|
|
1607
|
+
<h4>进度与静默监控</h4>
|
|
1508
1608
|
<p className="dshdg-hint">
|
|
1509
|
-
|
|
1510
|
-
<strong
|
|
1609
|
+
这两个时长量的是<strong>两件不同的事</strong>。
|
|
1610
|
+
<strong>程序自检</strong>从 DSH <strong>真正开始执行</strong>算起:排队、创建会话、请求受理都不算;
|
|
1611
|
+
模型和工具再活跃也不会推迟它,整个运行只自检一次。
|
|
1612
|
+
<strong>运行进度检查</strong>从<strong>最近一次真正回传给派工方的新成果</strong>算起(第一段基准是运行开始),
|
|
1613
|
+
不是"没有进展",也不是运行总时长:DSH 内部的模型输出、思考步骤、工具调用与结果,心跳、空轮询、页面刷新、
|
|
1614
|
+
等待授权或等待问题答复、重复失败提醒、检查本身,以及本机自检的结论,<strong>都不算新成果</strong>。
|
|
1615
|
+
当前等待通道只在任务结束时交付成果,所以运行一开始就长时间没有新交付的任务,会在约 40 分钟时被提醒一次。
|
|
1616
|
+
<strong>这些检查完全在本机进行,不会调用任何大模型,也不消耗 token;提醒只是提示,绝不取消、重启或重新提交任务。</strong>
|
|
1617
|
+
任一间隔填 <strong>0</strong> 即关闭对应提醒,两项可以分别关闭。
|
|
1511
1618
|
</p>
|
|
1512
1619
|
<div className="dshdg-grid">
|
|
1513
|
-
<
|
|
1620
|
+
<DurationField
|
|
1621
|
+
id="dshdg-monitoring-selfcheck"
|
|
1514
1622
|
label="程序自检间隔(分钟)"
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
/>
|
|
1531
|
-
</Field>
|
|
1532
|
-
<Field
|
|
1533
|
-
label="提醒你的间隔(分钟)"
|
|
1534
|
-
htmlFor="dshdg-monitoring-attention"
|
|
1535
|
-
hint={`${LIMITS.attentionSecondsMin / 60}–${LIMITS.attentionSecondsMax / 60} 分钟,且必须大于自检间隔;存成整秒(当前 ${raw.attentionSeconds === '' ? '未填' : `${raw.attentionSeconds} 秒`})`}
|
|
1536
|
-
>
|
|
1537
|
-
<input
|
|
1538
|
-
id="dshdg-monitoring-attention"
|
|
1539
|
-
type="number"
|
|
1540
|
-
inputMode="decimal"
|
|
1541
|
-
min={LIMITS.attentionSecondsMin / 60}
|
|
1542
|
-
max={LIMITS.attentionSecondsMax / 60}
|
|
1543
|
-
step={0.5}
|
|
1544
|
-
value={String(Number.isFinite(secondsToMinutes(raw.attentionSeconds)) ? secondsToMinutes(raw.attentionSeconds) : '')}
|
|
1545
|
-
onChange={(event) => {
|
|
1546
|
-
const value = event.target.value;
|
|
1547
|
-
edit('attentionSeconds', value === '' ? '' : value);
|
|
1548
|
-
}}
|
|
1549
|
-
/>
|
|
1550
|
-
</Field>
|
|
1623
|
+
field="selfCheckSeconds"
|
|
1624
|
+
value={raw.selfCheckSeconds}
|
|
1625
|
+
min={LIMITS.selfCheckSecondsMin}
|
|
1626
|
+
max={LIMITS.selfCheckSecondsMax}
|
|
1627
|
+
hint="DSH 开始执行后满这么久,本机只读检查一次,不需要你在看页面"
|
|
1628
|
+
/>
|
|
1629
|
+
<DurationField
|
|
1630
|
+
id="dshdg-monitoring-attention"
|
|
1631
|
+
label="运行进度检查(分钟)"
|
|
1632
|
+
field="attentionSeconds"
|
|
1633
|
+
value={raw.attentionSeconds}
|
|
1634
|
+
min={LIMITS.attentionSecondsMin}
|
|
1635
|
+
max={LIMITS.attentionSecondsMax}
|
|
1636
|
+
hint="从最近一次真实回传的新成果起算;两项都开启时必须大于自检间隔"
|
|
1637
|
+
/>
|
|
1551
1638
|
<Field
|
|
1552
1639
|
label="重复失败提醒(次)"
|
|
1553
1640
|
htmlFor="dshdg-monitoring-repeat"
|
|
@@ -1567,17 +1654,18 @@ function MonitoringCard({ store, snapshot }) {
|
|
|
1567
1654
|
</div>
|
|
1568
1655
|
{problems.length === 0 ? null : <p className="dshdg-fail">{problems.join(';')}</p>}
|
|
1569
1656
|
<ul className="dshdg-hint">
|
|
1570
|
-
<li
|
|
1571
|
-
<li
|
|
1572
|
-
<li
|
|
1657
|
+
<li>「没有新成果回传」本身不等于失败:插件不会因为安静、也不会因为单个工具跑得久就判定任务失败。</li>
|
|
1658
|
+
<li>只有<strong>连续</strong>没有新成果回传、并且超过「运行进度检查」之后,才会把这件事报告给派工方核对一次目标;同一段间隔最多报告一次,真实回传新成果后会重新计时。</li>
|
|
1659
|
+
<li>提醒不依赖任务总运行时长:跑上几小时但一直在回传新成果,就不会有提醒;也没有「总执行超时」这种按总时长中止的设置。</li>
|
|
1660
|
+
<li>重复失败提醒与上面两个间隔<strong>互相独立</strong>:它数的是同一操作连续失败了几次,而不是多久没有回传,所以正在忙碌地反复失败也会被提醒。它只提醒一次,不会自动取消任务或更换模型。</li>
|
|
1573
1661
|
<li>修改只影响<strong>之后新提交</strong>的任务;已经运行的任务保留它开始时的那份间隔快照。</li>
|
|
1574
|
-
<li
|
|
1662
|
+
<li>程序自检只读取本机已有的事实(任务是否还在、当前阶段、有没有待决定的调用、正在跑哪个工具,以及"未回传多久"和"DSH 正在做什么"),不读取代码差异,也不会读取你的文件内容;即使没有人正在等待,任务详情也能看到它已做的自检。读到自检结论只是读诊断,不会重置运行进度检查的计时。</li>
|
|
1575
1663
|
</ul>
|
|
1576
1664
|
<div className="dshdg-row" data-dshdg-monitoring-status="">
|
|
1577
1665
|
<span className="dshdg-hint" role="status" aria-live="polite">
|
|
1578
1666
|
{dirty
|
|
1579
1667
|
? '与已保存的值不同,正在自动保存(与整份设置走同一个串行保存队列)。'
|
|
1580
|
-
: `已保存:自检 ${saved.selfCheckSeconds}
|
|
1668
|
+
: `已保存:自检 ${saved.selfCheckSeconds} 秒,运行进度检查 ${saved.attentionSeconds} 秒。`}
|
|
1581
1669
|
</span>
|
|
1582
1670
|
</div>
|
|
1583
1671
|
<p className="dshdg-hint">
|
|
@@ -1587,6 +1675,93 @@ function MonitoringCard({ store, snapshot }) {
|
|
|
1587
1675
|
);
|
|
1588
1676
|
}
|
|
1589
1677
|
|
|
1678
|
+
/**
|
|
1679
|
+
* The operator's control over the Agent Teams default for NEW tasks.
|
|
1680
|
+
*
|
|
1681
|
+
* This is NOT DSH's global switch and it does not pretend to be: it decides only what a
|
|
1682
|
+
* NEW delegated task does when its dispatcher stated no per-task choice. Three facts the
|
|
1683
|
+
* card states, because each one is a place an operator could otherwise be surprised:
|
|
1684
|
+
*
|
|
1685
|
+
* 1. a per-task choice from the dispatcher always wins over this default;
|
|
1686
|
+
* 2. a follow-up (`continueFromTaskId`) keeps the mode of the task it continues, so this
|
|
1687
|
+
* default never flips a chain mid-way;
|
|
1688
|
+
* 3. it changes only later submissions — a task that already started keeps the decision
|
|
1689
|
+
* it froze at admission.
|
|
1690
|
+
*
|
|
1691
|
+
* A choice that CANNOT be applied (an older DSH without the service) is refused before
|
|
1692
|
+
* the worker is prompted, and the task detail says why; the card says so instead of
|
|
1693
|
+
* implying that "on" always means "on".
|
|
1694
|
+
* @param {object} props - `store`, `snapshot`.
|
|
1695
|
+
* @returns {object} the agent-teams card.
|
|
1696
|
+
*/
|
|
1697
|
+
function AgentTeamsCard({ store, snapshot }) {
|
|
1698
|
+
const draft = snapshot.draft;
|
|
1699
|
+
const raw = executionOf(draft).agentTeamsDefault;
|
|
1700
|
+
const saved = executionOf(snapshot.settings).agentTeamsDefault;
|
|
1701
|
+
const dirty = raw !== saved;
|
|
1702
|
+
const enabled = raw === true;
|
|
1703
|
+
/**
|
|
1704
|
+
* Write the switch as a discrete decision.
|
|
1705
|
+
*
|
|
1706
|
+
* A checkbox is one decision, not typing, so the draft edit is saved immediately
|
|
1707
|
+
* instead of waiting out the text debounce. The shared save queue keeps it serialized
|
|
1708
|
+
* with any other pending edit.
|
|
1709
|
+
* @param {boolean} next - the new default.
|
|
1710
|
+
* @returns {void}
|
|
1711
|
+
*/
|
|
1712
|
+
const edit = (next) => {
|
|
1713
|
+
store.editDraft((current) => {
|
|
1714
|
+
current.execution = { ...executionOf(current), agentTeamsDefault: next };
|
|
1715
|
+
}, { immediate: true });
|
|
1716
|
+
};
|
|
1717
|
+
return (
|
|
1718
|
+
<div className="dshdg-card" data-dshdg-agent-teams="">
|
|
1719
|
+
<h4>智能体协作(Agent Teams)</h4>
|
|
1720
|
+
<p className="dshdg-hint">
|
|
1721
|
+
这一项只决定<strong>新派工在看不出单次选择时</strong>用哪种协作方式,不是 DSH 的全局开关:
|
|
1722
|
+
插件只写这条任务自己的会话,不会打开 DSH 的全局「默认开启」,也不会影响你在 DSH 里手动改过设置的会话。
|
|
1723
|
+
</p>
|
|
1724
|
+
<label className="dshdg-row" htmlFor="dshdg-agent-teams-default">
|
|
1725
|
+
<input
|
|
1726
|
+
id="dshdg-agent-teams-default"
|
|
1727
|
+
type="checkbox"
|
|
1728
|
+
checked={enabled}
|
|
1729
|
+
onChange={(event) => { edit(event.target.checked); }}
|
|
1730
|
+
/>
|
|
1731
|
+
<span>新任务默认开启智能体协作</span>
|
|
1732
|
+
</label>
|
|
1733
|
+
<p className="dshdg-hint">
|
|
1734
|
+
当前已保存:<strong>{saved ? '新任务默认开启' : '新任务默认关闭'}</strong>。
|
|
1735
|
+
升级安装和首次安装都是<strong>关闭</strong>,插件不会替你打开。
|
|
1736
|
+
</p>
|
|
1737
|
+
<ul className="dshdg-hint">
|
|
1738
|
+
<li>派工方在单次派工里明确开/关时,<strong>以单次选择为准</strong>,这里的默认不生效。</li>
|
|
1739
|
+
<li>只影响<strong>之后新提交</strong>的任务;已经开始的任务保留它开始时冻结的选择,改这里不会改动它。</li>
|
|
1740
|
+
<li>
|
|
1741
|
+
续接已有任务(<code>continueFromTaskId</code>)且没有新的单次选择时:
|
|
1742
|
+
原任务记录过协作选择就<strong>沿用那条记录</strong>;
|
|
1743
|
+
原任务没有记录过(旧记录),插件<strong>不套用这里的默认、也不写入任何协作值</strong>,
|
|
1744
|
+
那条原生会话当前的选择保持不变。
|
|
1745
|
+
</li>
|
|
1746
|
+
<li>
|
|
1747
|
+
当前 DSH 没有智能体协作能力时,<strong>明确的开/关都会在发送提示词之前被拒绝并写明原因</strong>,
|
|
1748
|
+
不会悄悄按会话原有模式跑起来。只有「默认隐式关闭」这一种情况会继续执行,
|
|
1749
|
+
并如实报告<strong>未应用</strong>(不是「已关闭」),这样旧版本的普通派工仍然可用。
|
|
1750
|
+
</li>
|
|
1751
|
+
<li>一个外层任务始终只占<strong>一个会话和一个并发名额</strong>:子智能体由 DSH 大会话内部管理,不会额外占用本插件的名额。</li>
|
|
1752
|
+
<li>取消任务照常可用:随时可以取消运行中的任务,协作选择不影响取消。</li>
|
|
1753
|
+
</ul>
|
|
1754
|
+
<div className="dshdg-row" data-dshdg-agent-teams-status="">
|
|
1755
|
+
<span className="dshdg-hint" role="status" aria-live="polite">
|
|
1756
|
+
{dirty
|
|
1757
|
+
? '与已保存的值不同,正在自动保存(与整份设置走同一个串行保存队列)。'
|
|
1758
|
+
: `已保存:新任务默认${saved ? '开启' : '关闭'}智能体协作。`}
|
|
1759
|
+
</span>
|
|
1760
|
+
</div>
|
|
1761
|
+
</div>
|
|
1762
|
+
);
|
|
1763
|
+
}
|
|
1764
|
+
|
|
1590
1765
|
/** @param {object} props @returns {object} the execution settings panel. */
|
|
1591
1766
|
function ExecutionPanel({ store, snapshot }) {
|
|
1592
1767
|
const draft = snapshot.draft;
|
|
@@ -1617,24 +1792,13 @@ function ExecutionPanel({ store, snapshot }) {
|
|
|
1617
1792
|
}}
|
|
1618
1793
|
/>
|
|
1619
1794
|
<div className="dshdg-grid">
|
|
1620
|
-
<IntegerField
|
|
1621
|
-
id="dshdg-worker-timeout"
|
|
1622
|
-
label="超时(秒)"
|
|
1623
|
-
value={worker.timeoutSeconds}
|
|
1624
|
-
min={LIMITS.timeoutSecondsMin}
|
|
1625
|
-
max={LIMITS.timeoutSecondsMax}
|
|
1626
|
-
hint={`${LIMITS.timeoutSecondsMin}–${LIMITS.timeoutSecondsMax}`}
|
|
1627
|
-
onChange={(value) => {
|
|
1628
|
-
store.editDraft((current) => { current.worker.timeoutSeconds = value; });
|
|
1629
|
-
}}
|
|
1630
|
-
/>
|
|
1631
1795
|
<IntegerField
|
|
1632
1796
|
id="dshdg-worker-parallelism"
|
|
1633
1797
|
label="最大并发"
|
|
1634
1798
|
value={worker.maxParallelism}
|
|
1635
1799
|
min={LIMITS.maxParallelismMin}
|
|
1636
1800
|
max={LIMITS.maxParallelismMax}
|
|
1637
|
-
hint={`${LIMITS.maxParallelismMin}–${LIMITS.maxParallelismMax}
|
|
1801
|
+
hint={`${LIMITS.maxParallelismMin}–${LIMITS.maxParallelismMax},超出会被拒绝而不是自动调整。限制的是本插件同时接纳的派工数:按到达顺序争取名额,超出会被拒绝而不是排队;准备中、运行中和等待授权的任务都算占用,执行器确认结束后才让位。每个独立工作包各占一个名额;同一来源的隔离任务可开成独立会话并行,共享目录一次只跑一个;智能体协作的子智能体只在会话内部,不计入名额。`}
|
|
1638
1802
|
onChange={(value) => {
|
|
1639
1803
|
store.editDraft((current) => { current.worker.maxParallelism = value; });
|
|
1640
1804
|
}}
|
|
@@ -1664,6 +1828,11 @@ function ExecutionPanel({ store, snapshot }) {
|
|
|
1664
1828
|
</p>
|
|
1665
1829
|
</Field>
|
|
1666
1830
|
</div>
|
|
1831
|
+
<p className="dshdg-hint">
|
|
1832
|
+
任务<strong>没有总执行时长上限</strong>:不会因为跑得久被自动中止,只有你主动取消才会停止。
|
|
1833
|
+
长时间没有进展由下面的「进度与静默监控」提醒你判断,提醒本身不会取消、重启或重新提交任务。
|
|
1834
|
+
旧版本存下的「超时」值仍会被读取,但不再限制新任务。
|
|
1835
|
+
</p>
|
|
1667
1836
|
<p className="dshdg-hint">
|
|
1668
1837
|
不会自动回退到别的模型,也不会隐式使用 Harness 默认模型:选中的组合不可路由时任务直接拒绝。
|
|
1669
1838
|
</p>
|
|
@@ -1682,6 +1851,7 @@ function ExecutionPanel({ store, snapshot }) {
|
|
|
1682
1851
|
/>
|
|
1683
1852
|
)}
|
|
1684
1853
|
<MonitoringCard store={store} snapshot={snapshot} />
|
|
1854
|
+
<AgentTeamsCard store={store} snapshot={snapshot} />
|
|
1685
1855
|
{served === null ? (
|
|
1686
1856
|
<p className="dshdg-faint">宿主尚未回报实际生效值(模型目录不可用或尚未加载)。</p>
|
|
1687
1857
|
) : (
|
|
@@ -1697,78 +1867,53 @@ function ExecutionPanel({ store, snapshot }) {
|
|
|
1697
1867
|
}
|
|
1698
1868
|
|
|
1699
1869
|
// ---------------------------------------------------------------------------
|
|
1700
|
-
//
|
|
1870
|
+
// Task records
|
|
1701
1871
|
// ---------------------------------------------------------------------------
|
|
1702
1872
|
|
|
1703
|
-
/**
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
providers={providers}
|
|
1746
|
-
idPrefix="dshdg-review"
|
|
1747
|
-
value={{
|
|
1748
|
-
providerId: review.providerId ?? null,
|
|
1749
|
-
model: review.model ?? null,
|
|
1750
|
-
reasoningEffort: review.reasoningEffort ?? null,
|
|
1751
|
-
}}
|
|
1752
|
-
onChange={(next) => {
|
|
1753
|
-
// Review provider/model/effort are SELECTS: saved at once.
|
|
1754
|
-
store.editDraft((current) => {
|
|
1755
|
-
current.review.providerId = next.providerId;
|
|
1756
|
-
current.review.model = next.model;
|
|
1757
|
-
if ('reasoningEffort' in next) current.review.reasoningEffort = next.reasoningEffort;
|
|
1758
|
-
}, { immediate: true });
|
|
1759
|
-
}}
|
|
1760
|
-
/>
|
|
1761
|
-
) : (
|
|
1762
|
-
<p className="dshdg-faint">关闭时不创建审查代理,也不发出任何审查请求。</p>
|
|
1763
|
-
)}
|
|
1764
|
-
</div>
|
|
1765
|
-
);
|
|
1873
|
+
/**
|
|
1874
|
+
* One readable sentence about a task's Agent Teams decision, for the detail panel.
|
|
1875
|
+
*
|
|
1876
|
+
* The THREE facts are kept apart here on purpose, because collapsing them is how a
|
|
1877
|
+
* record starts lying about what happened:
|
|
1878
|
+
*
|
|
1879
|
+
* * the CHOICE that was frozen on the task (`agentTeams`) and where it came from
|
|
1880
|
+
* (`agentTeamsOrigin`) — a per-task request, an inherited chain, or the operator's
|
|
1881
|
+
* new-task default;
|
|
1882
|
+
* * what DSH actually CONFIRMED (`team.applied` / `team.enabled`);
|
|
1883
|
+
* * why it could not be applied (`team.reason`), which is a refusal, not a downgrade.
|
|
1884
|
+
*
|
|
1885
|
+
* A record written before the origin existed has no origin and is reported as such
|
|
1886
|
+
* rather than being attributed to anybody.
|
|
1887
|
+
* @param {object} task - task view.
|
|
1888
|
+
* @returns {string} the line.
|
|
1889
|
+
*/
|
|
1890
|
+
function teamLine(task) {
|
|
1891
|
+
const requested = typeof task?.agentTeams === 'boolean' ? task.agentTeams : null;
|
|
1892
|
+
if (requested === null) {
|
|
1893
|
+
// The honest "nothing was decided here" answer. It is what a continuation of a task
|
|
1894
|
+
// that recorded no choice looks like: the plugin applied nothing, so the native
|
|
1895
|
+
// Session keeps whatever mode it already had. Saying "off" would be a claim nobody
|
|
1896
|
+
// observed.
|
|
1897
|
+
return '本次未指定协作方式:原任务没有记录过选择,插件没有写入任何协作值,该会话保持它当前的选择。';
|
|
1898
|
+
}
|
|
1899
|
+
const origin = AGENT_TEAMS_ORIGIN_LABELS[task.agentTeamsOrigin] ?? '来源未记录';
|
|
1900
|
+
const choice = `选择「${requested ? '开启' : '关闭'}」· ${origin}`;
|
|
1901
|
+
const team = task.team;
|
|
1902
|
+
if (team === null || team === undefined) {
|
|
1903
|
+
return `${choice};本次运行尚未回报实际生效结果。`;
|
|
1904
|
+
}
|
|
1905
|
+
if (team.applied === true) {
|
|
1906
|
+
return `${choice};DSH 已确认本次会话实际为「${team.enabled === true ? '开启' : '关闭'}」。`;
|
|
1907
|
+
}
|
|
1908
|
+
if (team.reason === 'service-absent-default-off') {
|
|
1909
|
+
// The one case that proceeds without the capability: the operator's implicit off
|
|
1910
|
+
// default on a host that has no agent-teams service. It must NOT read as "off".
|
|
1911
|
+
return `${choice};当前 DSH 没有智能体协作能力,未应用(也没有声称该会话已关闭),任务照常执行。`;
|
|
1912
|
+
}
|
|
1913
|
+
const reason = typeof team.reason === 'string' && team.reason !== '' ? team.reason : '未说明原因';
|
|
1914
|
+
return `${choice};未能生效(${reason}),该任务不会在旧模式下继续执行。`;
|
|
1766
1915
|
}
|
|
1767
1916
|
|
|
1768
|
-
// ---------------------------------------------------------------------------
|
|
1769
|
-
// Task records
|
|
1770
|
-
// ---------------------------------------------------------------------------
|
|
1771
|
-
|
|
1772
1917
|
/**
|
|
1773
1918
|
* The full recorded review note of one task, expandable and copyable.
|
|
1774
1919
|
*
|
|
@@ -1848,6 +1993,40 @@ function ReviewNoteDetail({ task, store }) {
|
|
|
1848
1993
|
);
|
|
1849
1994
|
}
|
|
1850
1995
|
|
|
1996
|
+
function OpenTaskSession({ store, taskId }) {
|
|
1997
|
+
const navigation = useContext(SessionNavigation);
|
|
1998
|
+
const [opening, setOpening] = useState(false);
|
|
1999
|
+
const [feedback, setFeedback] = useState(null);
|
|
2000
|
+
// The list can restore a legacy record's session through its saved identity.
|
|
2001
|
+
const recorded = store.getSnapshot().tasks?.find((row) => row.taskId === taskId);
|
|
2002
|
+
const sessionId = taskSessionId(recorded);
|
|
2003
|
+
if (navigation === null) return null;
|
|
2004
|
+
|
|
2005
|
+
async function open() {
|
|
2006
|
+
setOpening(true);
|
|
2007
|
+
setFeedback(null);
|
|
2008
|
+
try {
|
|
2009
|
+
const outcome = await locateSession(
|
|
2010
|
+
resolveService(navigation.uiWorkspace), sessionId, resolveService(navigation.workspaces),
|
|
2011
|
+
);
|
|
2012
|
+
if (!outcome.ok) setFeedback(outcome.message);
|
|
2013
|
+
} finally {
|
|
2014
|
+
setOpening(false);
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
|
|
2018
|
+
return (
|
|
2019
|
+
<div className="dshdg-row">
|
|
2020
|
+
<button type="button" data-dshdg-open-session={taskId} disabled={opening || sessionId === null}
|
|
2021
|
+
onClick={() => { void open(); }}>
|
|
2022
|
+
打开会话
|
|
2023
|
+
</button>
|
|
2024
|
+
{sessionId === null ? <span className="dshdg-hint">这条记录没有可定位的会话。</span> : null}
|
|
2025
|
+
{feedback === null ? null : <span className="dshdg-warn" role="status">{feedback}</span>}
|
|
2026
|
+
</div>
|
|
2027
|
+
);
|
|
2028
|
+
}
|
|
2029
|
+
|
|
1851
2030
|
/**
|
|
1852
2031
|
* One task's details: effective config, diff, evidence, usage, review outcome.
|
|
1853
2032
|
* @param {object} props - `store`, `task`.
|
|
@@ -1864,8 +2043,11 @@ function TaskDetail({ store, task }) {
|
|
|
1864
2043
|
// `view()` freezes the configuration that actually ran; a later settings edit
|
|
1865
2044
|
// does not retroactively change what a finished task reports.
|
|
1866
2045
|
const worker = task.effective?.worker ?? {};
|
|
1867
|
-
const
|
|
1868
|
-
const
|
|
2046
|
+
const legacyReview = task.review;
|
|
2047
|
+
const legacyReviewState = legacyReview?.state;
|
|
2048
|
+
const legacyVerdict = typeof legacyReview?.verdict === 'string' ? legacyReview.verdict : legacyReview?.verdict?.verdict;
|
|
2049
|
+
const showLegacyReview = legacyReviewState === 'completed' || legacyReviewState === 'failed'
|
|
2050
|
+
|| legacyReviewState === 'cancelled';
|
|
1869
2051
|
const diff = task.diff ?? null;
|
|
1870
2052
|
const execution = task.execution ?? null;
|
|
1871
2053
|
const error = task.error ?? execution?.error ?? null;
|
|
@@ -1894,6 +2076,7 @@ function TaskDetail({ store, task }) {
|
|
|
1894
2076
|
</button>
|
|
1895
2077
|
</div>
|
|
1896
2078
|
<p className="dshdg-muted">{outcome.note}</p>
|
|
2079
|
+
<OpenTaskSession key={task.taskId} store={store} taskId={task.taskId} />
|
|
1897
2080
|
|
|
1898
2081
|
<div className="dshdg-card" data-dshdg-task-progress="">
|
|
1899
2082
|
<h4>进展</h4>
|
|
@@ -1955,19 +2138,16 @@ function TaskDetail({ store, task }) {
|
|
|
1955
2138
|
</dd>
|
|
1956
2139
|
<dt>重复失败提醒</dt>
|
|
1957
2140
|
<dd>{repeatFailureLine(activity)}</dd>
|
|
2141
|
+
<dt>智能体协作</dt>
|
|
2142
|
+
<dd data-dshdg-task-team="">
|
|
2143
|
+
{teamLine(task)}
|
|
2144
|
+
</dd>
|
|
1958
2145
|
<dt>创建</dt>
|
|
1959
2146
|
<dd>{formatTime(task.createdAt)}</dd>
|
|
1960
2147
|
<dt>结束</dt>
|
|
1961
2148
|
<dd>{formatTime(task.endedAt)}</dd>
|
|
1962
2149
|
<dt>用量</dt>
|
|
1963
2150
|
<dd>{execution?.usage === null || execution?.usage === undefined ? '不可用' : boundedText(execution.usage, 600)}</dd>
|
|
1964
|
-
<dt>附加审查</dt>
|
|
1965
|
-
<dd>
|
|
1966
|
-
{REVIEW_STATE_LABELS[reviewState] ?? reviewState}
|
|
1967
|
-
{review?.verdict === null || review?.verdict === undefined
|
|
1968
|
-
? ''
|
|
1969
|
-
: ` · ${REVIEW_VERDICT_LABELS[review.verdict] ?? review.verdict}`}
|
|
1970
|
-
</dd>
|
|
1971
2151
|
<dt>宿主验收</dt>
|
|
1972
2152
|
<dd>{hostReviewLine(task, formatTime)}</dd>
|
|
1973
2153
|
<dt>完整审查意见</dt>
|
|
@@ -1996,12 +2176,13 @@ function TaskDetail({ store, task }) {
|
|
|
1996
2176
|
</>
|
|
1997
2177
|
)}
|
|
1998
2178
|
|
|
1999
|
-
{
|
|
2000
|
-
|
|
2001
|
-
<
|
|
2002
|
-
<
|
|
2003
|
-
|
|
2004
|
-
|
|
2179
|
+
{showLegacyReview ? (
|
|
2180
|
+
<details>
|
|
2181
|
+
<summary>历史模型复审 · {REVIEW_STATE_LABELS[legacyReviewState] ?? legacyReviewState}</summary>
|
|
2182
|
+
{legacyVerdict ? <p>{REVIEW_VERDICT_LABELS[legacyVerdict] ?? legacyVerdict}</p> : null}
|
|
2183
|
+
{legacyReview.text ? <pre className="dshdg-pre">{boundedText(legacyReview.text, 8000)}</pre> : null}
|
|
2184
|
+
</details>
|
|
2185
|
+
) : null}
|
|
2005
2186
|
|
|
2006
2187
|
<h4>本次调用授权</h4>
|
|
2007
2188
|
<p className={isAwaitingPermission(task) ? 'dshdg-hint' : 'dshdg-faint'}>{permission.note}</p>
|
|
@@ -2051,102 +2232,32 @@ function TaskDetail({ store, task }) {
|
|
|
2051
2232
|
}
|
|
2052
2233
|
|
|
2053
2234
|
/** @param {object} props @returns {object} the task records panel. */
|
|
2054
|
-
/**
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
*
|
|
2059
|
-
* * it runs ONLY while the tasks tab is mounted (the effect lives in `TasksPanel`),
|
|
2060
|
-
* so switching tabs or unmounting clears the timer;
|
|
2061
|
-
* * it runs while any RECORD may still change — a running task, a task awaiting host
|
|
2062
|
-
* review, or a review that is still being written — not only while something is
|
|
2063
|
-
* executing. A finished run's conclusion is written by the commander, and a page that
|
|
2064
|
-
* stopped polling when execution ended would never show it;
|
|
2065
|
-
* * it stops once every visible record is settled (the conclusion is durable);
|
|
2066
|
-
* * it skips a hidden document and registers a `visibilitychange` listener so returning
|
|
2067
|
-
* to the tab reads immediately instead of waiting out the interval;
|
|
2068
|
-
* * it never overlaps: a refresh in flight suppresses the next tick;
|
|
2069
|
-
* * it is a pure read of the task list — no model call, no task action, no settings
|
|
2070
|
-
* write — so it cannot disturb an unsaved draft or the selected task;
|
|
2071
|
-
* * a failed refresh keeps the records already shown and states the failure.
|
|
2072
|
-
* @param {object} props - `store`, `snapshot`, `intervalMs`.
|
|
2073
|
-
* @returns {object | null} nothing (side effects only).
|
|
2074
|
-
*/
|
|
2075
|
-
function useTaskAutoRefresh({ store, snapshot, intervalMs = RECORD_REFRESH_INTERVAL_MS }) {
|
|
2076
|
-
const plan = recordRefreshPlan({
|
|
2235
|
+
/** Refresh the task list while this panel is mounted and the document is visible. */
|
|
2236
|
+
function useTaskAutoRefresh({ store, snapshot }) {
|
|
2237
|
+
const plan = recordRefreshPlan({ tasks: snapshot.tasks, selectedTask: snapshot.taskDetail });
|
|
2238
|
+
const latest = useRef({
|
|
2077
2239
|
tasks: snapshot.tasks,
|
|
2078
2240
|
selectedTask: snapshot.taskDetail,
|
|
2079
|
-
visible: globalThis.document?.hidden !== true,
|
|
2080
2241
|
loading: snapshot.loading?.tasks === true,
|
|
2242
|
+
hydrated: snapshot.tasksLoaded === true,
|
|
2081
2243
|
});
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
// faster than the interval.
|
|
2089
|
-
const changingRef = useRef(changing);
|
|
2090
|
-
changingRef.current = changing;
|
|
2244
|
+
latest.current = {
|
|
2245
|
+
tasks: snapshot.tasks,
|
|
2246
|
+
selectedTask: snapshot.taskDetail,
|
|
2247
|
+
loading: snapshot.loading?.tasks === true,
|
|
2248
|
+
hydrated: snapshot.tasksLoaded === true,
|
|
2249
|
+
};
|
|
2091
2250
|
const [refreshError, setRefreshError] = useState(null);
|
|
2092
2251
|
|
|
2093
2252
|
useEffect(() => {
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
timer = setTimeout(tick, intervalMs);
|
|
2103
|
-
timer.unref?.();
|
|
2104
|
-
};
|
|
2105
|
-
|
|
2106
|
-
const read = () => {
|
|
2107
|
-
if (inFlight) return;
|
|
2108
|
-
inFlight = true;
|
|
2109
|
-
setRefreshError(null);
|
|
2110
|
-
void store.refreshTasks('auto').then((result) => {
|
|
2111
|
-
// A failed read keeps the records already shown (the store does not clear them) and
|
|
2112
|
-
// is stated as a refresh problem — never as a lost task or a failed execution.
|
|
2113
|
-
if (result?.ok === false) setRefreshError(describeError(result.error));
|
|
2114
|
-
}).finally(() => {
|
|
2115
|
-
inFlight = false;
|
|
2116
|
-
schedule();
|
|
2117
|
-
});
|
|
2118
|
-
};
|
|
2119
|
-
|
|
2120
|
-
const tick = () => {
|
|
2121
|
-
timer = null;
|
|
2122
|
-
if (disposed) return;
|
|
2123
|
-
// A hidden tab is not watching anything: skip the read entirely, and let the
|
|
2124
|
-
// visibility listener below schedule the next one when it comes back.
|
|
2125
|
-
if (globalThis.document?.hidden === true) return;
|
|
2126
|
-
if (!changingRef.current) return;
|
|
2127
|
-
read();
|
|
2128
|
-
};
|
|
2129
|
-
|
|
2130
|
-
const onVisibility = () => {
|
|
2131
|
-
if (globalThis.document?.hidden === true) return;
|
|
2132
|
-
if (!changingRef.current) return;
|
|
2133
|
-
if (timer !== null) clearTimeout(timer);
|
|
2134
|
-
timer = null;
|
|
2135
|
-
// Coming back to the page reads once IMMEDIATELY: the operator must not wait out
|
|
2136
|
-
// an interval to see what changed while the tab was hidden.
|
|
2137
|
-
read();
|
|
2138
|
-
};
|
|
2139
|
-
|
|
2140
|
-
schedule();
|
|
2141
|
-
const doc = globalThis.document;
|
|
2142
|
-
doc?.addEventListener?.('visibilitychange', onVisibility);
|
|
2143
|
-
return () => {
|
|
2144
|
-
disposed = true;
|
|
2145
|
-
if (timer !== null) clearTimeout(timer);
|
|
2146
|
-
timer = null;
|
|
2147
|
-
doc?.removeEventListener?.('visibilitychange', onVisibility);
|
|
2148
|
-
};
|
|
2149
|
-
}, [store, changing, intervalMs]);
|
|
2253
|
+
// The SAME loop the sidebar view uses: one policy for every surface showing the
|
|
2254
|
+
// shared task records, so neither can miss a task dispatched from outside.
|
|
2255
|
+
return startRecordsReadLoop({
|
|
2256
|
+
store,
|
|
2257
|
+
readState: () => latest.current,
|
|
2258
|
+
onError: (error) => { setRefreshError(error === null ? null : describeError(error)); },
|
|
2259
|
+
});
|
|
2260
|
+
}, [store]);
|
|
2150
2261
|
return { ...plan, refreshError };
|
|
2151
2262
|
}
|
|
2152
2263
|
|
|
@@ -2188,7 +2299,11 @@ function autosaveLine(snapshot, problems) {
|
|
|
2188
2299
|
/**
|
|
2189
2300
|
* The review-note preview of one task row: at most 200 code points, plus a clear way to
|
|
2190
2301
|
* read the whole note. The preview is a display cut; the saved body is untouched.
|
|
2191
|
-
*
|
|
2302
|
+
*
|
|
2303
|
+
* `onOpen` takes the TASK ID, exactly like every other "open the detail" entry point on
|
|
2304
|
+
* this page. The row passes its own id (a bound call), so the link can never end up
|
|
2305
|
+
* reading whatever detail happens to be selected at click time.
|
|
2306
|
+
* @param {object} props - `task`, `onOpen(taskId)`.
|
|
2192
2307
|
* @returns {object | null} the preview line, or null when there is no conclusion.
|
|
2193
2308
|
*/
|
|
2194
2309
|
function TaskListNote({ task, onOpen }) {
|
|
@@ -2213,19 +2328,870 @@ function TaskListNote({ task, onOpen }) {
|
|
|
2213
2328
|
);
|
|
2214
2329
|
}
|
|
2215
2330
|
|
|
2331
|
+
// ---------------------------------------------------------------------------
|
|
2332
|
+
// Task tree (G09: visualise the host's projection) and plan creation (G02/G05)
|
|
2333
|
+
// ---------------------------------------------------------------------------
|
|
2334
|
+
//
|
|
2335
|
+
// Everything below renders the host's `/tasks` projection. It is deliberately a
|
|
2336
|
+
// READER: no relation is re-derived from titles, times, prompts or list order, and
|
|
2337
|
+
// no status is computed here — `nodeStatus`, `orphan`, `depth`, `executions` and
|
|
2338
|
+
// each chain's `rounds` all arrive from `src/jobs/task-tree.js` on the server. The
|
|
2339
|
+
// only additions are display text, and a Set of node ids the operator expanded.
|
|
2340
|
+
//
|
|
2341
|
+
// The one interaction the tree offers is a per-round "详情"/"取消", which reuse the
|
|
2342
|
+
// EXISTING store actions and the EXISTING `TaskDetail` panel. Every click carries a
|
|
2343
|
+
// stable `taskId`, so a later background refresh (which replaces the whole tree)
|
|
2344
|
+
// cannot re-point a button at a different task.
|
|
2345
|
+
//
|
|
2346
|
+
// "清理记录" adds ONE more: selection mode. While it is on, every execution chain
|
|
2347
|
+
// of the tree gets a checkbox whose state comes from the host's own `cleanup` block
|
|
2348
|
+
// (`eligible` + `blockers`). The selection holds the chain's EXACT task ids, the bar
|
|
2349
|
+
// counts them before anything is sent, and only a confirmed batch is written. Cancel
|
|
2350
|
+
// sends nothing, and the panel never deletes on render, on refresh or on open.
|
|
2351
|
+
|
|
2352
|
+
/** How many rounds of one chain are listed without expanding that chain further. */
|
|
2353
|
+
const CHAIN_ROUNDS_VISIBLE = 3;
|
|
2354
|
+
|
|
2355
|
+
/**
|
|
2356
|
+
* Whether `node` is visible, given the set of COLLAPSED keys.
|
|
2357
|
+
*
|
|
2358
|
+
* The model is "expanded by default, minus what the operator collapsed", not "a
|
|
2359
|
+
* fresh set of open ids". A background refresh replaces every node object, so an
|
|
2360
|
+
* expansion state kept as "open ids" would silently re-collapse everything the
|
|
2361
|
+
* operator had opened (the bug this shape prevents): a retained set of CLOSED keys
|
|
2362
|
+
* survives the replacement and keeps the tree exactly as the operator left it.
|
|
2363
|
+
* @param {object} node - projected node (its `nodeId` is the identity).
|
|
2364
|
+
* @param {Set<string>} collapsed - keys the operator closed.
|
|
2365
|
+
* @returns {boolean} true when the node itself should be drawn.
|
|
2366
|
+
*/
|
|
2367
|
+
function isNodeVisible(node, collapsed) {
|
|
2368
|
+
return !collapsed.has(node.nodeId);
|
|
2369
|
+
}
|
|
2370
|
+
|
|
2371
|
+
/** Display title of one node: the host's own (a missing one is already labelled upstream). */
|
|
2372
|
+
function treeNodeTitle(node) {
|
|
2373
|
+
if (typeof node.displayTitle === 'string' && node.displayTitle !== '') return node.displayTitle;
|
|
2374
|
+
if (typeof node.title === 'string' && node.title !== '') return node.title;
|
|
2375
|
+
return '未命名节点';
|
|
2376
|
+
}
|
|
2377
|
+
|
|
2378
|
+
/**
|
|
2379
|
+
* The node ids a create form may offer as a parent, in tree order.
|
|
2380
|
+
*
|
|
2381
|
+
* It lists exactly what the host returned: a node id from the projection, with its
|
|
2382
|
+
* title as the label. The SELECTED value is the real id, so "same title in two
|
|
2383
|
+
* projects" stays two distinct choices, and nothing is inferred from a title.
|
|
2384
|
+
* @param {object | null} view - `taskTreeView(...)`.
|
|
2385
|
+
* @returns {object[]} `{ nodeId, label, depth }` entries.
|
|
2386
|
+
*/
|
|
2387
|
+
function planParentChoices(view) {
|
|
2388
|
+
if (view === null || view === undefined) return [];
|
|
2389
|
+
const choices = [];
|
|
2390
|
+
const walk = (node, depth) => {
|
|
2391
|
+
if (node === null || typeof node !== 'object' || typeof node.nodeId !== 'string') return;
|
|
2392
|
+
if (node.kind === 'plan') choices.push({ nodeId: node.nodeId, label: treeNodeTitle(node), depth });
|
|
2393
|
+
for (const child of Array.isArray(node.children) ? node.children : []) walk(child, depth + 1);
|
|
2394
|
+
};
|
|
2395
|
+
for (const root of Array.isArray(view.roots) ? view.roots : []) walk(root, 0);
|
|
2396
|
+
return choices;
|
|
2397
|
+
}
|
|
2398
|
+
|
|
2399
|
+
function chainsOfTreeNode(node) {
|
|
2400
|
+
if (node.kind === 'plan') return node.executions ?? [];
|
|
2401
|
+
return node.chain ? [node.chain] : [];
|
|
2402
|
+
}
|
|
2403
|
+
|
|
2404
|
+
/**
|
|
2405
|
+
* One execution chain: its rounds, plus — in selection mode — its cleanup checkbox.
|
|
2406
|
+
*
|
|
2407
|
+
* The checkbox is the ONLY control that changes the cleanup selection, and it is
|
|
2408
|
+
* driven entirely by the host's `cleanup` block on this chain: a chain the host says
|
|
2409
|
+
* is ineligible is drawn disabled with the reason, so a refusal can never be produced
|
|
2410
|
+
* by a row the page offered as removable.
|
|
2411
|
+
* @param {object} props - `chain`, `store`, `snapshot`, `onOpen`, `expanded`, `onToggle`,
|
|
2412
|
+
* `cleanup` (`{ active, selection, candidates, onToggle }` or null), `forceExpanded`,
|
|
2413
|
+
* `newestFirst` (draw the last round, i.e. the one carrying the live session, first).
|
|
2414
|
+
* @returns {object} the chain block.
|
|
2415
|
+
*/
|
|
2416
|
+
function ChainRounds({ chain, store, snapshot, onOpen, expanded, onToggle, cleanup, forceExpanded, newestFirst = false }) {
|
|
2417
|
+
const ordered = chain.rounds ?? [];
|
|
2418
|
+
// The NEWEST round is the only one that can still own a live native session, so the
|
|
2419
|
+
// 最近任务 detail lists it first; the PROJECT TREE keeps the recorded order (first
|
|
2420
|
+
// round, then rectification rounds), which is what the operator reads there.
|
|
2421
|
+
const rounds = newestFirst ? [...ordered].reverse() : ordered;
|
|
2422
|
+
const roundOf = (task) => (ordered.findIndex((entry) => entry.taskId === task.taskId) + 1);
|
|
2423
|
+
const candidate = cleanup?.candidates?.find((entry) => entry.chainId === chain.chainId) ?? null;
|
|
2424
|
+
const checked = candidate !== null
|
|
2425
|
+
&& Array.isArray(cleanup?.selection?.[chain.chainId]);
|
|
2426
|
+
return (
|
|
2427
|
+
<div className="dshdg-tree-execution" data-dshdg-chain={chain.chainId}>
|
|
2428
|
+
{cleanup?.active === true && candidate !== null ? (
|
|
2429
|
+
<div className="dshdg-cleanup-row" data-dshdg-cleanup-row={chain.chainId}>
|
|
2430
|
+
<label className="dshdg-cleanup-check">
|
|
2431
|
+
<input
|
|
2432
|
+
type="checkbox"
|
|
2433
|
+
data-dshdg-cleanup-check={chain.chainId}
|
|
2434
|
+
checked={checked}
|
|
2435
|
+
disabled={!candidate.selectable || snapshot.loading?.cleanup === true}
|
|
2436
|
+
onChange={() => cleanup.onToggle(candidate)}
|
|
2437
|
+
/>
|
|
2438
|
+
{`勾选整条执行链(${candidate.taskIds.length} 轮)`}
|
|
2439
|
+
</label>
|
|
2440
|
+
{candidate.selectable ? null : (
|
|
2441
|
+
<span className="dshdg-faint" data-dshdg-cleanup-blocked={chain.chainId}>{candidate.reason}</span>
|
|
2442
|
+
)}
|
|
2443
|
+
</div>
|
|
2444
|
+
) : null}
|
|
2445
|
+
<ul className="dshdg-tree-rounds">
|
|
2446
|
+
{rounds.map((task, index) => (newestFirst
|
|
2447
|
+
|| expanded || forceExpanded || index >= rounds.length - CHAIN_ROUNDS_VISIBLE
|
|
2448
|
+
|| task.taskId === snapshot.taskDetail?.taskId ? (
|
|
2449
|
+
<ChainRoundRow key={task.taskId} store={store} round={{ task, round: roundOf(task),
|
|
2450
|
+
position: roundOf(task) === 1 ? 'first' : 'rectification' }} snapshot={snapshot} onOpen={onOpen} />
|
|
2451
|
+
) : null))}
|
|
2452
|
+
</ul>
|
|
2453
|
+
{!forceExpanded && !newestFirst && rounds.length > CHAIN_ROUNDS_VISIBLE ? <button type="button" data-dshdg-chain-more={chain.chainId}
|
|
2454
|
+
onClick={onToggle} aria-expanded={expanded}>
|
|
2455
|
+
{expanded ? '只看最近三轮' : '显示全部 ' + rounds.length + ' 轮'}
|
|
2456
|
+
</button> : null}
|
|
2457
|
+
</div>
|
|
2458
|
+
);
|
|
2459
|
+
}
|
|
2460
|
+
|
|
2461
|
+
function InlineTaskDetail({ store, task, view, onClose }) {
|
|
2462
|
+
const detailRef = useRef(null);
|
|
2463
|
+
useLayoutEffect(() => {
|
|
2464
|
+
const element = detailRef.current;
|
|
2465
|
+
element?.focus({ preventScroll: true });
|
|
2466
|
+
element?.scrollIntoView?.({ block: 'nearest' });
|
|
2467
|
+
}, [view]);
|
|
2468
|
+
return (
|
|
2469
|
+
<div ref={detailRef} tabIndex={-1} data-dshdg-task-detail="" aria-label="任务详情">
|
|
2470
|
+
<div className="dshdg-row">
|
|
2471
|
+
<button type="button" onClick={onClose}>收起详情</button>
|
|
2472
|
+
</div>
|
|
2473
|
+
<TaskDetail store={store} task={task} />
|
|
2474
|
+
</div>
|
|
2475
|
+
);
|
|
2476
|
+
}
|
|
2477
|
+
|
|
2478
|
+
function ChainRoundRow({ store, round, snapshot, onOpen }) {
|
|
2479
|
+
const task = round.task ?? {};
|
|
2480
|
+
const outcome = taskOutcome(task);
|
|
2481
|
+
const progress = taskProgress(task);
|
|
2482
|
+
const model = task.route?.model ?? task.effective?.worker?.model ?? null;
|
|
2483
|
+
const activityAt = task.activity?.lastActivityAt;
|
|
2484
|
+
const detailButton = useRef(null);
|
|
2485
|
+
const detail = snapshot.taskDetail?.taskId === task.taskId ? snapshot.taskDetail : null;
|
|
2486
|
+
return (
|
|
2487
|
+
<li className="dshdg-tree-round" data-dshdg-round={`${task.taskId ?? ''}`}>
|
|
2488
|
+
<div className="dshdg-tree-round-head">
|
|
2489
|
+
<span className="dshdg-faint dshdg-mono">{`第 ${round.round} 轮`}</span>
|
|
2490
|
+
<span>{task.title || task.taskId || '未记录标题'}</span>
|
|
2491
|
+
<Badge tone={isAwaitingPermission(task) ? 'warn' : outcome.tone}>{outcome.label}</Badge>
|
|
2492
|
+
<span className="dshdg-spacer" />
|
|
2493
|
+
{round.position === 'first' ? <span className="dshdg-faint">首轮</span> : <span className="dshdg-faint">整改轮次</span>}
|
|
2494
|
+
<button
|
|
2495
|
+
type="button"
|
|
2496
|
+
ref={detailButton}
|
|
2497
|
+
aria-expanded={detail !== null}
|
|
2498
|
+
data-dshdg-round-detail={task.taskId ?? ''}
|
|
2499
|
+
disabled={snapshot.taskDetailLoading === true}
|
|
2500
|
+
onClick={() => { void onOpen(task.taskId); }}
|
|
2501
|
+
>
|
|
2502
|
+
详情
|
|
2503
|
+
</button>
|
|
2504
|
+
<button
|
|
2505
|
+
type="button"
|
|
2506
|
+
className="dshdg-danger"
|
|
2507
|
+
data-dshdg-round-cancel={task.taskId ?? ''}
|
|
2508
|
+
disabled={!isCancellable(task.state)}
|
|
2509
|
+
onClick={() => { void store.cancelTask(task.taskId); }}
|
|
2510
|
+
>
|
|
2511
|
+
取消
|
|
2512
|
+
</button>
|
|
2513
|
+
</div>
|
|
2514
|
+
{detail ? null : (
|
|
2515
|
+
<p className="dshdg-hint">
|
|
2516
|
+
{[progress.headline, model, Number.isFinite(activityAt) ? `最近活动 ${formatTime(activityAt)}` : null].filter(Boolean).join(' · ')}
|
|
2517
|
+
</p>
|
|
2518
|
+
)}
|
|
2519
|
+
{typeof task.hostAcceptance?.note === 'string' && task.hostAcceptance.note !== ''
|
|
2520
|
+
? <p className="dshdg-hint dshdg-note-preview">{`审查意见:${boundedText(task.hostAcceptance.note, 200)}`}</p>
|
|
2521
|
+
: null}
|
|
2522
|
+
{detail === null ? null : (
|
|
2523
|
+
<InlineTaskDetail store={store} task={detail} view={snapshot.taskDetailView} onClose={() => {
|
|
2524
|
+
store.closeTask();
|
|
2525
|
+
detailButton.current?.focus({ preventScroll: true });
|
|
2526
|
+
}} />
|
|
2527
|
+
)}
|
|
2528
|
+
</li>
|
|
2529
|
+
);
|
|
2530
|
+
}
|
|
2531
|
+
|
|
2532
|
+
/**
|
|
2533
|
+
* One projected node: header, goals, completion, children and every chain round.
|
|
2534
|
+
*
|
|
2535
|
+
* Accessibility/behaviour choices that are load-bearing:
|
|
2536
|
+
* * the expand/collapse control is a real `<button>` with `aria-expanded` and
|
|
2537
|
+
* `aria-controls`, so it is reachable and operable by keyboard; Enter and Space
|
|
2538
|
+
* both reach it through the native button behaviour;
|
|
2539
|
+
* * the indented child list is a `<ul role="group">`, which is the structure a
|
|
2540
|
+
* screen reader announces as a nested group;
|
|
2541
|
+
* * nothing focuses itself on render, so a refresh cannot steal focus;
|
|
2542
|
+
* * a `plan` node with no execution and no execution anywhere below it is drawn
|
|
2543
|
+
* as unexecuted, and the page never labels it "done".
|
|
2544
|
+
* @param {object} props - `node`, `store`, `snapshot`, `collapsed`, `setCollapsed`,
|
|
2545
|
+
* `expandedRounds`, `setExpandedRounds`, `onOpen`.
|
|
2546
|
+
* @returns {object} the node.
|
|
2547
|
+
*/
|
|
2548
|
+
function TaskTreeItem({ node, store, snapshot, collapsed, setCollapsed, expandedRounds, setExpandedRounds, onOpen, onArchive, forceOpen, cleanup }) {
|
|
2549
|
+
const children = Array.isArray(node.children) ? node.children : [];
|
|
2550
|
+
const key = node.nodeId;
|
|
2551
|
+
const open = forceOpen || !collapsed.has(key);
|
|
2552
|
+
const status = typeof node.nodeStatus === 'string' ? node.nodeStatus : 'unknown';
|
|
2553
|
+
const chains = chainsOfTreeNode(node);
|
|
2554
|
+
const orphanLabel = node.orphan === null || node.orphan === undefined
|
|
2555
|
+
? null
|
|
2556
|
+
: (TREE_ORPHAN_LABELS[node.orphan.kind] ?? '关系不完整,暂列在此');
|
|
2557
|
+
const goal = typeof node.goalDescription === 'string' && node.goalDescription.trim() !== ''
|
|
2558
|
+
? node.goalDescription.trim()
|
|
2559
|
+
: null;
|
|
2560
|
+
const completion = typeof node.completionSummary === 'string' && node.completionSummary.trim() !== ''
|
|
2561
|
+
? node.completionSummary.trim()
|
|
2562
|
+
: null;
|
|
2563
|
+
const toggle = () => {
|
|
2564
|
+
const next = new Set(collapsed);
|
|
2565
|
+
if (next.has(key)) next.delete(key);
|
|
2566
|
+
else next.add(key);
|
|
2567
|
+
setCollapsed(next);
|
|
2568
|
+
};
|
|
2569
|
+
return (
|
|
2570
|
+
<li className="dshdg-tree-node" data-dshdg-tree-node={key} data-dshdg-node-kind={node.kind ?? 'unknown'}>
|
|
2571
|
+
<div className="dshdg-tree-row">
|
|
2572
|
+
<button
|
|
2573
|
+
type="button"
|
|
2574
|
+
className="dshdg-tree-toggle"
|
|
2575
|
+
data-dshdg-tree-toggle={key}
|
|
2576
|
+
aria-expanded={open}
|
|
2577
|
+
aria-controls={`dshdg-tree-children-${key}`}
|
|
2578
|
+
disabled={forceOpen}
|
|
2579
|
+
onClick={toggle}
|
|
2580
|
+
>
|
|
2581
|
+
{open ? '收起' : '展开'}
|
|
2582
|
+
</button>
|
|
2583
|
+
<span className="dshdg-tree-title">{treeNodeTitle(node)}</span>
|
|
2584
|
+
<Badge tone={TREE_STATUS_TONES[status] ?? 'off'}>{TREE_STATUS_LABELS[status] ?? status}</Badge>
|
|
2585
|
+
{node.kind === 'plan' && node.executed !== true
|
|
2586
|
+
? <span className="dshdg-faint">尚未执行</span>
|
|
2587
|
+
: null}
|
|
2588
|
+
{node.kind === 'task' && node.standalone === true ? <span className="dshdg-faint">独立任务</span> : null}
|
|
2589
|
+
{node.childProgress?.total > 0 ? <span className="dshdg-faint">{`子任务 ${node.childProgress.total} · ${node.childProgress.accepted} 已通过`}</span> : null}
|
|
2590
|
+
{onArchive && !node.displayArchiveInherited && (node.displayArchived || status === 'accepted') ? (
|
|
2591
|
+
<button type="button" disabled={snapshot.loading?.displayArchive === true}
|
|
2592
|
+
onClick={() => { void onArchive(node, !node.displayArchived); }}>
|
|
2593
|
+
{node.displayArchived ? '恢复显示' : '归档'}
|
|
2594
|
+
</button>
|
|
2595
|
+
) : null}
|
|
2596
|
+
{typeof node.roundCount === 'number' && node.roundCount > 0
|
|
2597
|
+
? <span className="dshdg-faint">{`${node.roundCount} 轮`}</span>
|
|
2598
|
+
: null}
|
|
2599
|
+
</div>
|
|
2600
|
+
{orphanLabel === null ? null : <p className="dshdg-warn">{orphanLabel}</p>}
|
|
2601
|
+
{open ? (
|
|
2602
|
+
<div id={`dshdg-tree-children-${key}`} className="dshdg-tree-body">
|
|
2603
|
+
{goal === null ? null : <p className="dshdg-hint">{`目标:${boundedText(goal, 400)}`}</p>}
|
|
2604
|
+
{completion === null ? null : <p className="dshdg-hint">{`已完成:${boundedText(completion, 400)}`}</p>}
|
|
2605
|
+
{chains.map((chain) => <ChainRounds key={chain.chainId} chain={chain} store={store} snapshot={snapshot}
|
|
2606
|
+
onOpen={onOpen} expanded={expandedRounds.has(chain.chainId)} forceExpanded={forceOpen}
|
|
2607
|
+
cleanup={cleanup} onToggle={() => setExpandedRounds((old) => {
|
|
2608
|
+
const next = new Set(old);
|
|
2609
|
+
if (next.has(chain.chainId)) next.delete(chain.chainId);
|
|
2610
|
+
else next.add(chain.chainId);
|
|
2611
|
+
return next;
|
|
2612
|
+
})} />)}
|
|
2613
|
+
{children.length === 0 ? null : (
|
|
2614
|
+
<ul className="dshdg-tree-children" role="group" aria-label={`${treeNodeTitle(node)} 的子节点`}>
|
|
2615
|
+
{children.map((child) => (
|
|
2616
|
+
<TaskTreeItem
|
|
2617
|
+
key={child.nodeId}
|
|
2618
|
+
node={child}
|
|
2619
|
+
store={store}
|
|
2620
|
+
snapshot={snapshot}
|
|
2621
|
+
collapsed={collapsed}
|
|
2622
|
+
setCollapsed={setCollapsed}
|
|
2623
|
+
expandedRounds={expandedRounds}
|
|
2624
|
+
setExpandedRounds={setExpandedRounds}
|
|
2625
|
+
onOpen={onOpen}
|
|
2626
|
+
onArchive={onArchive}
|
|
2627
|
+
forceOpen={forceOpen}
|
|
2628
|
+
cleanup={cleanup}
|
|
2629
|
+
/>
|
|
2630
|
+
))}
|
|
2631
|
+
</ul>
|
|
2632
|
+
)}
|
|
2633
|
+
</div>
|
|
2634
|
+
) : null}
|
|
2635
|
+
</li>
|
|
2636
|
+
);
|
|
2637
|
+
}
|
|
2638
|
+
|
|
2639
|
+
function TaskTreePanel({ store, snapshot, onOpen }) {
|
|
2640
|
+
const view = snapshot.tree ?? null;
|
|
2641
|
+
const [recordView, setRecordView] = useState('recent');
|
|
2642
|
+
const [collapsed, setCollapsed] = useState(() => new Set());
|
|
2643
|
+
const [expandedRounds, setExpandedRounds] = useState(() => new Set());
|
|
2644
|
+
const [projectKey, setProjectKey] = useState('');
|
|
2645
|
+
const [filter, setFilter] = useState('all');
|
|
2646
|
+
const [search, setSearch] = useState('');
|
|
2647
|
+
const [fromDay, setFromDay] = useState('');
|
|
2648
|
+
const [toDay, setToDay] = useState('');
|
|
2649
|
+
const [archiveError, setArchiveError] = useState(null);
|
|
2650
|
+
// Selection mode. `cleanupSelection` maps a chain id to the EXACT task ids that
|
|
2651
|
+
// were ticked; `cleanupConfirm` opens the confirmation, which is the only place a
|
|
2652
|
+
// batch is sent. Leaving the mode (or cancelling) clears both.
|
|
2653
|
+
const [cleanupMode, setCleanupMode] = useState(false);
|
|
2654
|
+
const [cleanupSelection, setCleanupSelection] = useState({});
|
|
2655
|
+
const [cleanupConfirm, setCleanupConfirm] = useState(false);
|
|
2656
|
+
if (view === null) {
|
|
2657
|
+
return <p className="dshdg-faint" data-dshdg-tree-unavailable="">
|
|
2658
|
+
{snapshot.tasksError ? '任务树读取失败,下面显示已有记录。' : '当前宿主按列表显示任务。'}
|
|
2659
|
+
</p>;
|
|
2660
|
+
}
|
|
2661
|
+
const counts = view.counts ?? {};
|
|
2662
|
+
const canArchive = view.displayArchiveAvailable === true;
|
|
2663
|
+
const dateRange = { from: fromDay, to: toDay };
|
|
2664
|
+
const { groups, recent, archiveCount, dateError, dateRangeText } = projectTaskView(view, {
|
|
2665
|
+
projectKey, filter: canArchive ? filter : (filter === 'archive' ? 'all' : filter), search,
|
|
2666
|
+
selectedTaskId: snapshot.taskDetail?.taskId ?? null,
|
|
2667
|
+
dateRange,
|
|
2668
|
+
});
|
|
2669
|
+
// A reversed range is stated and NOT applied: the page keeps showing what it
|
|
2670
|
+
// showed before rather than answering a different question than the one asked.
|
|
2671
|
+
// The projection has already applied exactly the same rule to the same values.
|
|
2672
|
+
const rangeActive = dateError === null && (dateRange.from !== '' || dateRange.to !== '');
|
|
2673
|
+
const roots = recordView === 'recent'
|
|
2674
|
+
? recent.map(({ chain, node }) => ({ nodeId: node.nodeId, kind: node.kind, chain }))
|
|
2675
|
+
: groups.flatMap((group) => group.roots);
|
|
2676
|
+
const candidates = cleanupCandidates({ roots });
|
|
2677
|
+
const canCleanup = view.cleanupAvailable === true && (view.counts?.taskChains ?? 0) > 0;
|
|
2678
|
+
const cleanupActive = cleanupMode && canCleanup;
|
|
2679
|
+
const cleanupBusy = snapshot.loading?.cleanup === true;
|
|
2680
|
+
const summary = cleanupSelectionSummary(cleanupSelection, candidates);
|
|
2681
|
+
const mayDelete = dateError === null && !cleanupBusy && summary.executable;
|
|
2682
|
+
function clearSelection() {
|
|
2683
|
+
setCleanupSelection({});
|
|
2684
|
+
setCleanupConfirm(false);
|
|
2685
|
+
}
|
|
2686
|
+
const updateFilter = (setter) => (event) => {
|
|
2687
|
+
setter(event.target.value);
|
|
2688
|
+
clearSelection();
|
|
2689
|
+
store.closeTask();
|
|
2690
|
+
};
|
|
2691
|
+
const clearDays = () => {
|
|
2692
|
+
setFromDay('');
|
|
2693
|
+
setToDay('');
|
|
2694
|
+
clearSelection();
|
|
2695
|
+
store.closeTask();
|
|
2696
|
+
};
|
|
2697
|
+
async function archive(node, archived) {
|
|
2698
|
+
setArchiveError(null);
|
|
2699
|
+
const result = await store.setDisplayArchive(node.nodeId, archived);
|
|
2700
|
+
if (!result.ok) setArchiveError(describeError(result.error));
|
|
2701
|
+
else if (archived && snapshot.taskDetail) store.closeTask();
|
|
2702
|
+
}
|
|
2703
|
+
function leaveCleanup() {
|
|
2704
|
+
setCleanupMode(false);
|
|
2705
|
+
clearSelection();
|
|
2706
|
+
}
|
|
2707
|
+
function onToggleChain(candidate) {
|
|
2708
|
+
setCleanupSelection((old) => toggleCleanupSelection(old, withSelectionState(candidate, old[candidate.chainId])));
|
|
2709
|
+
setCleanupConfirm(false);
|
|
2710
|
+
}
|
|
2711
|
+
async function confirmCleanup() {
|
|
2712
|
+
if (!mayDelete) return;
|
|
2713
|
+
const result = await store.cleanupTasks(cleanupSelection);
|
|
2714
|
+
if (result.ok) leaveCleanup();
|
|
2715
|
+
setCleanupConfirm(false);
|
|
2716
|
+
}
|
|
2717
|
+
const cleanup = cleanupActive ? { active: true, selection: cleanupSelection, candidates, onToggle: onToggleChain } : null;
|
|
2718
|
+
function changeView(next) {
|
|
2719
|
+
if (recordView === next) return;
|
|
2720
|
+
setRecordView(next);
|
|
2721
|
+
clearSelection();
|
|
2722
|
+
store.closeTask();
|
|
2723
|
+
}
|
|
2724
|
+
/**
|
|
2725
|
+
* A 最近任务 row was just expanded: read ITS most recent round through the same
|
|
2726
|
+
* `store.openTask` every other 详情 entry uses, so the row's detail block shows the
|
|
2727
|
+
* existing `TaskDetail` — including the existing 打开会话 control and the rounds a
|
|
2728
|
+
* continuation chain has. A collapsed row reads nothing.
|
|
2729
|
+
* @param {object} chain - the row's execution chain.
|
|
2730
|
+
* @returns {void}
|
|
2731
|
+
*/
|
|
2732
|
+
function openRecentDetail(chain) {
|
|
2733
|
+
const rounds = Array.isArray(chain?.rounds) ? chain.rounds : [];
|
|
2734
|
+
const latest = rounds[rounds.length - 1];
|
|
2735
|
+
const taskId = latest?.taskId;
|
|
2736
|
+
if (typeof taskId === 'string' && taskId !== '') void store.openTask(taskId);
|
|
2737
|
+
}
|
|
2738
|
+
function renderRecordDetails({ chain, node, archiveInherited }) {
|
|
2739
|
+
const mayArchive = canArchive && node.kind === 'task' && !archiveInherited
|
|
2740
|
+
&& (node.displayArchived || chain.nodeStatus === 'accepted');
|
|
2741
|
+
return (
|
|
2742
|
+
<div className="dshdg-record-detail">
|
|
2743
|
+
{chain.goalDescription ? <p className="dshdg-hint">{'目标:' + boundedText(chain.goalDescription, 400)}</p> : null}
|
|
2744
|
+
{chain.completionSummary ? <p className="dshdg-hint">{'已完成:' + boundedText(chain.completionSummary, 400)}</p> : null}
|
|
2745
|
+
{/* The chain's rounds, newest LAST round first so 打开会话 is in reach without
|
|
2746
|
+
scrolling past every older round; the row above already shows the count. */}
|
|
2747
|
+
<ChainRounds chain={chain} store={store} snapshot={snapshot} onOpen={onOpen} forceExpanded newestFirst />
|
|
2748
|
+
{mayArchive ? (
|
|
2749
|
+
<button type="button" disabled={snapshot.loading?.displayArchive === true}
|
|
2750
|
+
onClick={() => { void archive(node, !node.displayArchived); }}>
|
|
2751
|
+
{node.displayArchived ? '恢复显示' : '归档'}
|
|
2752
|
+
</button>
|
|
2753
|
+
) : null}
|
|
2754
|
+
</div>
|
|
2755
|
+
);
|
|
2756
|
+
}
|
|
2757
|
+
return (
|
|
2758
|
+
<section className="dshdg-card" aria-labelledby="dshdg-tree-title" data-dshdg-task-tree="">
|
|
2759
|
+
<div className="dshdg-row">
|
|
2760
|
+
<h3 id="dshdg-tree-title">任务记录</h3>
|
|
2761
|
+
<span className="dshdg-spacer" />
|
|
2762
|
+
<div className="dshdg-record-views" role="group" aria-label="显示方式">
|
|
2763
|
+
<button type="button" aria-pressed={recordView === 'recent'} onClick={() => changeView('recent')} data-dshdg-record-view="recent">
|
|
2764
|
+
最近任务
|
|
2765
|
+
</button>
|
|
2766
|
+
<button type="button" aria-pressed={recordView === 'tree'} onClick={() => changeView('tree')} data-dshdg-record-view="tree">
|
|
2767
|
+
项目树
|
|
2768
|
+
</button>
|
|
2769
|
+
</div>
|
|
2770
|
+
{canCleanup ? (
|
|
2771
|
+
<button
|
|
2772
|
+
type="button"
|
|
2773
|
+
className={cleanupActive ? 'dshdg-danger' : undefined}
|
|
2774
|
+
data-dshdg-cleanup-toggle=""
|
|
2775
|
+
aria-pressed={cleanupActive}
|
|
2776
|
+
disabled={cleanupBusy || (!cleanupActive && dateError !== null)}
|
|
2777
|
+
onClick={() => {
|
|
2778
|
+
if (cleanupActive) leaveCleanup();
|
|
2779
|
+
else {
|
|
2780
|
+
setCleanupMode(true);
|
|
2781
|
+
setCleanupConfirm(false);
|
|
2782
|
+
}
|
|
2783
|
+
}}
|
|
2784
|
+
>
|
|
2785
|
+
{cleanupActive ? '退出清理' : '清理记录'}
|
|
2786
|
+
</button>
|
|
2787
|
+
) : null}
|
|
2788
|
+
</div>
|
|
2789
|
+
<div className="dshdg-tree-filters">
|
|
2790
|
+
<label>项目<select value={projectKey} onChange={updateFilter(setProjectKey)}>
|
|
2791
|
+
<option value="">所有项目</option>
|
|
2792
|
+
{view.projects.map((p) => <option key={p.projectKey} value={p.projectKey}>{p.shortPath ? `${p.name} · ${p.shortPath}` : p.name}</option>)}
|
|
2793
|
+
</select></label>
|
|
2794
|
+
<label>状态<select value={filter} onChange={updateFilter(setFilter)}>
|
|
2795
|
+
<option value="all">全部</option>
|
|
2796
|
+
<option value="attention">需要处理</option>
|
|
2797
|
+
<option value="active">执行中</option>
|
|
2798
|
+
<option value="done">已完成</option>
|
|
2799
|
+
{canArchive ? <option value="archive">{`已归档(${archiveCount})`}</option> : null}
|
|
2800
|
+
</select></label>
|
|
2801
|
+
<label>搜索<input type="search" value={search} onChange={updateFilter(setSearch)} placeholder="项目、标题或任务编号" /></label>
|
|
2802
|
+
<label>创建日期(起)<input type="date" value={fromDay} data-dshdg-tree-day-from="" max={toDay === '' ? undefined : toDay}
|
|
2803
|
+
aria-invalid={dateError !== null} onChange={updateFilter(setFromDay)} /></label>
|
|
2804
|
+
<label>创建日期(止)<input type="date" value={toDay} data-dshdg-tree-day-to="" min={fromDay === '' ? undefined : fromDay}
|
|
2805
|
+
aria-invalid={dateError !== null} onChange={updateFilter(setToDay)} /></label>
|
|
2806
|
+
<span className="dshdg-tree-day-actions">
|
|
2807
|
+
<button type="button" data-dshdg-tree-day-clear="" disabled={!rangeActive && dateError === null}
|
|
2808
|
+
onClick={clearDays}>清除日期</button>
|
|
2809
|
+
</span>
|
|
2810
|
+
</div>
|
|
2811
|
+
<p className="dshdg-hint" data-dshdg-tree-day-hint="">
|
|
2812
|
+
{rangeActive
|
|
2813
|
+
? `按创建日期筛选:${dateRangeText.from ?? '不限'} 至 ${dateRangeText.to ?? '不限'}(两端都含当天;任一整改轮次创建于该范围时保留整条链)`
|
|
2814
|
+
: '按创建日期筛选:可只填开始或结束日期。两端相同时查询当天。'}
|
|
2815
|
+
</p>
|
|
2816
|
+
{dateError === null ? null : <p className="dshdg-warn" role="alert" data-dshdg-tree-day-error="">{`${dateError}。日期筛选未生效,任务树仍按其它条件显示。`}</p>}
|
|
2817
|
+
{filter === 'archive' ? <p className="dshdg-hint">归档只影响任务的显示。会话和历史仍按原规则保留。</p> : null}
|
|
2818
|
+
{view.displayArchiveError ? <p className="dshdg-warn" role="alert">归档记录暂不可读,已显示全部任务。</p> : null}
|
|
2819
|
+
{archiveError ? <p className="dshdg-warn" role="alert">{`更新归档失败。${archiveError}`}</p> : null}
|
|
2820
|
+
{view.cleanupError && view.cleanupError !== 'CLEANUP_UNAVAILABLE' ? (
|
|
2821
|
+
<p className="dshdg-warn" role="alert">清理状态暂不可用,任务树照常显示。</p>
|
|
2822
|
+
) : null}
|
|
2823
|
+
{cleanupActive ? (
|
|
2824
|
+
<div className="dshdg-cleanup-bar" data-dshdg-cleanup-bar="">
|
|
2825
|
+
<p className="dshdg-hint" data-dshdg-cleanup-counts="">
|
|
2826
|
+
{`已选 ${summary.chains} 条执行链 / 共 ${summary.rounds} 轮`}
|
|
2827
|
+
</p>
|
|
2828
|
+
{cleanupConfirm ? null : <p className="dshdg-warn">{cleanupWarningText()}</p>}
|
|
2829
|
+
{Object.keys(cleanupSelection).length === 0 ? null : summary.problems.map((problem) => (
|
|
2830
|
+
<p className="dshdg-warn" role="alert" key={problem} data-dshdg-cleanup-problem="">{problem}</p>
|
|
2831
|
+
))}
|
|
2832
|
+
{cleanupConfirm ? (
|
|
2833
|
+
<div className="dshdg-row" data-dshdg-cleanup-confirm-dialog="" role="alertdialog" aria-label="确认永久删除记录">
|
|
2834
|
+
<span>
|
|
2835
|
+
{`确认永久删除 ${summary.chains} 条执行链、共 ${summary.rounds} 轮的任务记录及审查意见?删除后无法按任务编号查询或续接。DSH 会话、工作区与源文件不会被删除。`}
|
|
2836
|
+
</span>
|
|
2837
|
+
<button
|
|
2838
|
+
type="button"
|
|
2839
|
+
className="dshdg-danger"
|
|
2840
|
+
data-dshdg-cleanup-confirm=""
|
|
2841
|
+
disabled={!mayDelete}
|
|
2842
|
+
onClick={() => { void confirmCleanup(); }}
|
|
2843
|
+
>
|
|
2844
|
+
{snapshot.loading?.cleanup === true ? '正在删除…' : '确认删除'}
|
|
2845
|
+
</button>
|
|
2846
|
+
<button type="button" data-dshdg-cleanup-cancel="" disabled={cleanupBusy} onClick={() => setCleanupConfirm(false)}>取消</button>
|
|
2847
|
+
</div>
|
|
2848
|
+
) : (
|
|
2849
|
+
<div className="dshdg-row">
|
|
2850
|
+
<button
|
|
2851
|
+
type="button"
|
|
2852
|
+
className="dshdg-danger"
|
|
2853
|
+
data-dshdg-cleanup-review=""
|
|
2854
|
+
disabled={!mayDelete}
|
|
2855
|
+
onClick={() => setCleanupConfirm(true)}
|
|
2856
|
+
>
|
|
2857
|
+
下一步:确认删除
|
|
2858
|
+
</button>
|
|
2859
|
+
<button type="button" data-dshdg-cleanup-reset="" onClick={clearSelection}>
|
|
2860
|
+
清空选择
|
|
2861
|
+
</button>
|
|
2862
|
+
</div>
|
|
2863
|
+
)}
|
|
2864
|
+
</div>
|
|
2865
|
+
) : null}
|
|
2866
|
+
{recordView === 'recent' ? (
|
|
2867
|
+
<TaskRecordsTable records={recent} hasPlans={counts.planNodes > 0} hasRecords={counts.taskChains > 0}
|
|
2868
|
+
cleanup={cleanup} cleanupBusy={cleanupBusy} renderDetails={renderRecordDetails} onToggleExpand={openRecentDetail} />
|
|
2869
|
+
) : groups.length === 0 ? (
|
|
2870
|
+
<p className="dshdg-faint" data-dshdg-tree-empty="">{view.roots.length === 0 ? '还没有规划节点或执行记录。' : '没有符合当前条件的任务。'}</p>
|
|
2871
|
+
) : groups.map((group) => (
|
|
2872
|
+
<section className="dshdg-tree-project" key={group.projectKey} data-dshdg-project={group.projectKey}>
|
|
2873
|
+
<h4>{group.name} {group.shortPath ? <small>{group.shortPath}</small> : null}</h4>
|
|
2874
|
+
<p className="dshdg-hint">{`任务 ${group.count.total} · 需要处理 ${group.count.attention}`}</p>
|
|
2875
|
+
<ul className="dshdg-tree-roots">
|
|
2876
|
+
{group.roots.map((node) => <TaskTreeItem key={node.nodeId} node={node} store={store} snapshot={snapshot}
|
|
2877
|
+
collapsed={collapsed} setCollapsed={setCollapsed} expandedRounds={expandedRounds} setExpandedRounds={setExpandedRounds}
|
|
2878
|
+
onOpen={onOpen} onArchive={canArchive ? archive : null}
|
|
2879
|
+
forceOpen={search.trim() !== '' || filter !== 'all' || rangeActive || cleanupActive}
|
|
2880
|
+
cleanup={cleanup} />)}
|
|
2881
|
+
</ul>
|
|
2882
|
+
</section>
|
|
2883
|
+
))}
|
|
2884
|
+
</section>
|
|
2885
|
+
);
|
|
2886
|
+
}
|
|
2887
|
+
|
|
2888
|
+
/**
|
|
2889
|
+
* One editable batch row of the creation form.
|
|
2890
|
+
*
|
|
2891
|
+
* `parent` is one of:
|
|
2892
|
+
* * `''` — a root row (a top-level node, unless the form's own
|
|
2893
|
+
* "关联父节点" selector attaches the batch);
|
|
2894
|
+
* * `'row:<n>'` — an EARLIER row of the same batch (by position);
|
|
2895
|
+
* * a real plan `nodeId` — an existing node the host returned.
|
|
2896
|
+
* Nothing else is expressible, which is what keeps a parent reference an identity
|
|
2897
|
+
* rather than a guess from a title.
|
|
2898
|
+
*/
|
|
2899
|
+
function emptyPlanRow(overrides = {}) {
|
|
2900
|
+
return {
|
|
2901
|
+
title: '',
|
|
2902
|
+
goalDescription: '',
|
|
2903
|
+
parent: '',
|
|
2904
|
+
...overrides,
|
|
2905
|
+
};
|
|
2906
|
+
}
|
|
2907
|
+
|
|
2908
|
+
/**
|
|
2909
|
+
* The plan-creation form (G09 batch create).
|
|
2910
|
+
*
|
|
2911
|
+
* Rules it keeps:
|
|
2912
|
+
* * the parent selector offers ONLY real ids the host returned (a plan node id) or
|
|
2913
|
+
* a row position from the SAME batch — never a title, never a guessed parent;
|
|
2914
|
+
* * a row may name another row as its parent (`parentKey` after projection), which
|
|
2915
|
+
* is what makes "add one deeper level" possible without a second round trip;
|
|
2916
|
+
* * the batch is created in ONE request, so the host's atomic validation decides:
|
|
2917
|
+
* either every row exists or none does;
|
|
2918
|
+
* * a refusal keeps every field exactly as typed and shows the host's reason;
|
|
2919
|
+
* * success reads the records back through the normal refresh, so nothing here
|
|
2920
|
+
* invents ids, order or statuses;
|
|
2921
|
+
* * it never dispatches, authorizes or approves execution — the text says so.
|
|
2922
|
+
* @param {object} props - `store`, `snapshot`, `view`.
|
|
2923
|
+
* @returns {object} the form.
|
|
2924
|
+
*/
|
|
2925
|
+
function PlanCreateForm({ store, snapshot, view }) {
|
|
2926
|
+
const [open, setOpen] = useState(false);
|
|
2927
|
+
const [draft, setDraft] = useState(() => ({
|
|
2928
|
+
title: '',
|
|
2929
|
+
goal: '',
|
|
2930
|
+
parentNodeId: '',
|
|
2931
|
+
workspacePath: '',
|
|
2932
|
+
rows: [emptyPlanRow()],
|
|
2933
|
+
}));
|
|
2934
|
+
const [problems, setProblems] = useState([]);
|
|
2935
|
+
const [saved, setSaved] = useState(null);
|
|
2936
|
+
const openerRef = useRef(null);
|
|
2937
|
+
const formRef = useRef(null);
|
|
2938
|
+
const error = snapshot.planCreateError ?? null;
|
|
2939
|
+
const busy = snapshot.loading?.planCreate === true;
|
|
2940
|
+
const choices = planParentChoices(view);
|
|
2941
|
+
// A parent picked from the tree keeps offering exactly that id even when the node is
|
|
2942
|
+
// currently COLLAPSED (and therefore absent from the visible choices), so collapsing
|
|
2943
|
+
// a subtree can never silently clear the parent the operator selected. The entry is
|
|
2944
|
+
// still an id the host returned, never a title.
|
|
2945
|
+
const selectedParent = draft.parentNodeId === '' || choices.some((choice) => choice.nodeId === draft.parentNodeId)
|
|
2946
|
+
? null
|
|
2947
|
+
: { nodeId: draft.parentNodeId };
|
|
2948
|
+
const close = () => {
|
|
2949
|
+
setOpen(false);
|
|
2950
|
+
// Focus returns to the button that opened the form, so a keyboard operator is
|
|
2951
|
+
// never dropped back to the top of a long page (Escape does the same).
|
|
2952
|
+
openerRef.current?.focus?.();
|
|
2953
|
+
};
|
|
2954
|
+
const openForm = () => {
|
|
2955
|
+
setOpen(true);
|
|
2956
|
+
setSaved(null);
|
|
2957
|
+
setProblems([]);
|
|
2958
|
+
};
|
|
2959
|
+
const edit = (patchDraft) => setDraft((current) => ({ ...current, ...patchDraft }));
|
|
2960
|
+
const updateRow = (index, patchRow) => {
|
|
2961
|
+
setDraft((current) => ({
|
|
2962
|
+
...current,
|
|
2963
|
+
rows: current.rows.map((row, at) => (at === index ? { ...row, ...patchRow } : row)),
|
|
2964
|
+
}));
|
|
2965
|
+
};
|
|
2966
|
+
const addRow = () => {
|
|
2967
|
+
setDraft((current) => (current.rows.length >= 32
|
|
2968
|
+
// A new row is a CHILD of the row above by default: that is the "add a deeper
|
|
2969
|
+
// level in one batch" gesture, and it is always expressed as a real row link.
|
|
2970
|
+
? current
|
|
2971
|
+
: { ...current, rows: [...current.rows, emptyPlanRow({ parent: `row:${current.rows.length - 1}` })] }));
|
|
2972
|
+
};
|
|
2973
|
+
const removeRow = (index) => {
|
|
2974
|
+
setDraft((current) => (current.rows.length <= 1
|
|
2975
|
+
? current
|
|
2976
|
+
: {
|
|
2977
|
+
...current,
|
|
2978
|
+
// Positions shift after a removal, so a link into a removed (or renumbered)
|
|
2979
|
+
// row is dropped rather than left pointing at a different node.
|
|
2980
|
+
rows: current.rows
|
|
2981
|
+
.filter((_row, at) => at !== index)
|
|
2982
|
+
.map((row) => (row.parent.startsWith('row:') && Number.parseInt(row.parent.slice(4), 10) >= index
|
|
2983
|
+
? { ...row, parent: '' }
|
|
2984
|
+
: row)),
|
|
2985
|
+
}));
|
|
2986
|
+
};
|
|
2987
|
+
const submit = async () => {
|
|
2988
|
+
const request = planCreateRequest(draft);
|
|
2989
|
+
setProblems(request.problems);
|
|
2990
|
+
if (request.problems.length > 0) return;
|
|
2991
|
+
const outcome = await store.createPlans(request.body);
|
|
2992
|
+
if (outcome?.ok !== true) return;
|
|
2993
|
+
// ONLY a confirmed create clears the form. A refusal keeps everything, so the
|
|
2994
|
+
// operator fixes the one field the host objected to instead of retyping a batch.
|
|
2995
|
+
setDraft({ title: '', goal: '', parentNodeId: '', workspacePath: '', rows: [emptyPlanRow()] });
|
|
2996
|
+
setSaved(outcome.nodes ?? []);
|
|
2997
|
+
setOpen(false);
|
|
2998
|
+
openerRef.current?.focus?.();
|
|
2999
|
+
};
|
|
3000
|
+
return (
|
|
3001
|
+
<section className="dshdg-card" aria-labelledby="dshdg-plan-create-title" data-dshdg-plan-create="">
|
|
3002
|
+
<div className="dshdg-row">
|
|
3003
|
+
<h3 id="dshdg-plan-create-title">规划任务节点</h3>
|
|
3004
|
+
<span className="dshdg-spacer" />
|
|
3005
|
+
<button
|
|
3006
|
+
type="button"
|
|
3007
|
+
ref={openerRef}
|
|
3008
|
+
data-dshdg-plan-create-open=""
|
|
3009
|
+
aria-expanded={open}
|
|
3010
|
+
aria-controls="dshdg-plan-create-form"
|
|
3011
|
+
disabled={busy}
|
|
3012
|
+
onClick={() => { if (open) close(); else openForm(); }}
|
|
3013
|
+
>
|
|
3014
|
+
{open ? '关闭' : '新建规划'}
|
|
3015
|
+
</button>
|
|
3016
|
+
</div>
|
|
3017
|
+
<p className="dshdg-hint">
|
|
3018
|
+
这里只记录计划:创建节点不会派发任务、不会授权执行,也不会替你验收。
|
|
3019
|
+
</p>
|
|
3020
|
+
{saved === null ? null : (
|
|
3021
|
+
<p className="dshdg-hint" role="status" data-dshdg-plan-create-result="">
|
|
3022
|
+
{`已创建 ${saved.length} 个规划节点,可在上方任务树中查看。`}
|
|
3023
|
+
</p>
|
|
3024
|
+
)}
|
|
3025
|
+
{error === null ? null : (
|
|
3026
|
+
<p className="dshdg-warn" role="alert" data-dshdg-plan-create-error="">
|
|
3027
|
+
{`创建失败:${describeError(error)} 已保留你填写的全部内容;整批没有保存任何节点。`}
|
|
3028
|
+
</p>
|
|
3029
|
+
)}
|
|
3030
|
+
{problems.length === 0 ? null : (
|
|
3031
|
+
<p className="dshdg-warn" role="alert" data-dshdg-plan-create-problems="">
|
|
3032
|
+
{`请先修正:${problems.join(';')}。`}
|
|
3033
|
+
</p>
|
|
3034
|
+
)}
|
|
3035
|
+
{open ? (
|
|
3036
|
+
<div
|
|
3037
|
+
id="dshdg-plan-create-form"
|
|
3038
|
+
ref={formRef}
|
|
3039
|
+
className="dshdg-card"
|
|
3040
|
+
role="group"
|
|
3041
|
+
aria-label="新建规划节点"
|
|
3042
|
+
onKeyDown={(event) => {
|
|
3043
|
+
// Escape closes the form from ANY field inside it, which is what a
|
|
3044
|
+
// keyboard operator expects; the input is kept, only the form closes.
|
|
3045
|
+
if (event.key === 'Escape') {
|
|
3046
|
+
event.stopPropagation();
|
|
3047
|
+
close();
|
|
3048
|
+
}
|
|
3049
|
+
}}
|
|
3050
|
+
>
|
|
3051
|
+
<div className="dshdg-grid">
|
|
3052
|
+
<Field label="标题" htmlFor="dshdg-plan-title" hint="第一个根节点的名称(1–120 个字)">
|
|
3053
|
+
<input
|
|
3054
|
+
id="dshdg-plan-title"
|
|
3055
|
+
type="text"
|
|
3056
|
+
value={draft.title}
|
|
3057
|
+
data-dshdg-plan-title=""
|
|
3058
|
+
onChange={(event) => edit({ title: event.target.value })}
|
|
3059
|
+
/>
|
|
3060
|
+
</Field>
|
|
3061
|
+
<Field label="目标" htmlFor="dshdg-plan-goal" hint="可选:这个根节点要达成什么">
|
|
3062
|
+
<input
|
|
3063
|
+
id="dshdg-plan-goal"
|
|
3064
|
+
type="text"
|
|
3065
|
+
value={draft.goal}
|
|
3066
|
+
data-dshdg-plan-goal=""
|
|
3067
|
+
onChange={(event) => edit({ goal: event.target.value })}
|
|
3068
|
+
/>
|
|
3069
|
+
</Field>
|
|
3070
|
+
{draft.parentNodeId === '' ? <Field label="所属项目" htmlFor="dshdg-plan-project">
|
|
3071
|
+
<select id="dshdg-plan-project" value={draft.workspacePath}
|
|
3072
|
+
onChange={(event) => edit({ workspacePath: event.target.value })}>
|
|
3073
|
+
<option value="">暂不指定</option>
|
|
3074
|
+
{(view?.projects ?? []).filter((project) => project.sourcePath && !project.unverified).map((project) => (
|
|
3075
|
+
<option key={project.projectKey} value={project.sourcePath}>{project.name} {project.shortPath}</option>
|
|
3076
|
+
))}
|
|
3077
|
+
</select>
|
|
3078
|
+
</Field> : null}
|
|
3079
|
+
<Field label="关联父节点" htmlFor="dshdg-plan-parent">
|
|
3080
|
+
<select
|
|
3081
|
+
id="dshdg-plan-parent"
|
|
3082
|
+
value={draft.parentNodeId}
|
|
3083
|
+
data-dshdg-plan-parent=""
|
|
3084
|
+
onChange={(event) => edit({ parentNodeId: event.target.value, workspacePath: '' })}
|
|
3085
|
+
>
|
|
3086
|
+
<option value="">(不关联,作为顶层)</option>
|
|
3087
|
+
{selectedParent === null ? null : (
|
|
3088
|
+
<option value={selectedParent.nodeId}>{`(已选,当前不可见)${selectedParent.nodeId}`}</option>
|
|
3089
|
+
)}
|
|
3090
|
+
{choices.map((choice) => (
|
|
3091
|
+
<option key={choice.nodeId} value={choice.nodeId}>
|
|
3092
|
+
{`${' '.repeat(Math.min(choice.depth, 6))}${choice.label}(${choice.nodeId})`}
|
|
3093
|
+
</option>
|
|
3094
|
+
))}
|
|
3095
|
+
</select>
|
|
3096
|
+
</Field>
|
|
3097
|
+
</div>
|
|
3098
|
+
<h4>同批节点</h4>
|
|
3099
|
+
<ul className="dshdg-list">
|
|
3100
|
+
{draft.rows.map((row, index) => (
|
|
3101
|
+
<li className="dshdg-item" key={`plan-row-${index}`}>
|
|
3102
|
+
<div className="dshdg-row">
|
|
3103
|
+
<span className="dshdg-faint dshdg-mono">{`第 ${index + 1} 行`}</span>
|
|
3104
|
+
<span className="dshdg-spacer" />
|
|
3105
|
+
<button type="button" disabled={draft.rows.length <= 1} onClick={() => removeRow(index)}>
|
|
3106
|
+
移除
|
|
3107
|
+
</button>
|
|
3108
|
+
</div>
|
|
3109
|
+
<div className="dshdg-grid">
|
|
3110
|
+
<Field label="节点标题" htmlFor={`dshdg-plan-row-title-${index}`}>
|
|
3111
|
+
<input
|
|
3112
|
+
id={`dshdg-plan-row-title-${index}`}
|
|
3113
|
+
type="text"
|
|
3114
|
+
value={row.title}
|
|
3115
|
+
data-dshdg-plan-row-title={index}
|
|
3116
|
+
onChange={(event) => updateRow(index, { title: event.target.value })}
|
|
3117
|
+
/>
|
|
3118
|
+
</Field>
|
|
3119
|
+
<Field label="节点目标" htmlFor={`dshdg-plan-row-goal-${index}`}>
|
|
3120
|
+
<input
|
|
3121
|
+
id={`dshdg-plan-row-goal-${index}`}
|
|
3122
|
+
type="text"
|
|
3123
|
+
value={row.goalDescription}
|
|
3124
|
+
data-dshdg-plan-row-goal={index}
|
|
3125
|
+
onChange={(event) => updateRow(index, { goalDescription: event.target.value })}
|
|
3126
|
+
/>
|
|
3127
|
+
</Field>
|
|
3128
|
+
<Field label="父节点" htmlFor={`dshdg-plan-row-parent-${index}`} hint="可选:选本批的另一行,可一次建出更深一级">
|
|
3129
|
+
<select
|
|
3130
|
+
id={`dshdg-plan-row-parent-${index}`}
|
|
3131
|
+
value={row.parent}
|
|
3132
|
+
data-dshdg-plan-row-parent={index}
|
|
3133
|
+
onChange={(event) => updateRow(index, { parent: event.target.value })}
|
|
3134
|
+
>
|
|
3135
|
+
<option value="">{index === 0 ? '(不关联,作为顶层)' : '(与第一行同级)'}</option>
|
|
3136
|
+
{draft.rows.map((_candidate, at) => (at === index ? null : (
|
|
3137
|
+
<option key={`row-option-${at}`} value={`row:${at}`}>{`第 ${at + 1} 行`}</option>
|
|
3138
|
+
)))}
|
|
3139
|
+
</select>
|
|
3140
|
+
</Field>
|
|
3141
|
+
</div>
|
|
3142
|
+
</li>
|
|
3143
|
+
))}
|
|
3144
|
+
</ul>
|
|
3145
|
+
<div className="dshdg-row">
|
|
3146
|
+
<button type="button" data-dshdg-plan-add-row="" disabled={busy || draft.rows.length >= 32} onClick={addRow}>
|
|
3147
|
+
再加一行(作为上一行的子节点)
|
|
3148
|
+
</button>
|
|
3149
|
+
<span className="dshdg-spacer" />
|
|
3150
|
+
<button type="button" onClick={close}>取消</button>
|
|
3151
|
+
<button
|
|
3152
|
+
type="button"
|
|
3153
|
+
className="dshdg-primary"
|
|
3154
|
+
data-dshdg-plan-create-submit=""
|
|
3155
|
+
disabled={busy}
|
|
3156
|
+
onClick={() => { void submit(); }}
|
|
3157
|
+
>
|
|
3158
|
+
{busy ? '创建中…' : '创建规划'}
|
|
3159
|
+
</button>
|
|
3160
|
+
</div>
|
|
3161
|
+
</div>
|
|
3162
|
+
) : null}
|
|
3163
|
+
</section>
|
|
3164
|
+
);
|
|
3165
|
+
}
|
|
3166
|
+
|
|
2216
3167
|
function TasksPanel({ store, snapshot }) {
|
|
2217
3168
|
const tasks = snapshot.tasks ?? [];
|
|
2218
3169
|
const detail = snapshot.taskDetail;
|
|
2219
3170
|
const plan = useTaskAutoRefresh({ store, snapshot });
|
|
2220
3171
|
const liveCount = tasks.filter(isLiveTask).length;
|
|
2221
3172
|
const detailRef = useRef(null);
|
|
3173
|
+
/**
|
|
3174
|
+
* Open one task's detail from ANYWHERE in this panel (tree round, flat row, note).
|
|
3175
|
+
*
|
|
3176
|
+
* One handler for every entry point, so the tree cannot grow a second, subtly
|
|
3177
|
+
* different way of opening a task. It is the store's existing action: the same
|
|
3178
|
+
* request, the same refusal reporting, the same focus/scroll counter.
|
|
3179
|
+
* @param {string} taskId - stable task identity from the projection.
|
|
3180
|
+
* @returns {void}
|
|
3181
|
+
*/
|
|
3182
|
+
const openTask = useCallback((taskId) => {
|
|
3183
|
+
if (typeof taskId !== 'string' || taskId === '') return;
|
|
3184
|
+
void store.openTask(taskId);
|
|
3185
|
+
}, [store]);
|
|
3186
|
+
const treeView = snapshot.tree ?? null;
|
|
3187
|
+
const flatOnly = treeView === null;
|
|
2222
3188
|
// The dependency is the count of SUCCESSFUL opens, not the task object: a background
|
|
2223
3189
|
// list refresh recomposes `taskDetail` (same task, merged row) and must NOT steal the
|
|
2224
3190
|
// operator's focus. A first open, a repeat open of the SAME task and a switch to a
|
|
2225
3191
|
// DIFFERENT task each bump the counter, so each one focuses and scrolls.
|
|
2226
3192
|
const detailView = snapshot.taskDetailView ?? 0;
|
|
2227
3193
|
useLayoutEffect(() => {
|
|
2228
|
-
if (detailView === 0) return;
|
|
3194
|
+
if (detailView === 0 || !flatOnly) return;
|
|
2229
3195
|
const node = detailRef.current;
|
|
2230
3196
|
if (node === null || node === undefined) return;
|
|
2231
3197
|
try {
|
|
@@ -2238,7 +3204,7 @@ function TasksPanel({ store, snapshot }) {
|
|
|
2238
3204
|
} catch {
|
|
2239
3205
|
// Scrolling is best-effort; focus already moved the operator's reading point.
|
|
2240
3206
|
}
|
|
2241
|
-
}, [detailView]);
|
|
3207
|
+
}, [detailView, flatOnly]);
|
|
2242
3208
|
const changing = hasChangingRecords([
|
|
2243
3209
|
...tasks,
|
|
2244
3210
|
...(detail === null || detail === undefined ? [] : [detail]),
|
|
@@ -2248,9 +3214,9 @@ function TasksPanel({ store, snapshot }) {
|
|
|
2248
3214
|
<div className="dshdg-row">
|
|
2249
3215
|
<p className="dshdg-muted">这里只记录执行事实。执行完成不等于被接受:“等待宿主审查”要由宿主(例如 Codex)单独给出结论。</p>
|
|
2250
3216
|
<span className="dshdg-spacer" />
|
|
2251
|
-
<span className="dshdg-hint">
|
|
3217
|
+
<span className="dshdg-hint" data-dshdg-refresh-hint="">
|
|
2252
3218
|
{changing !== true
|
|
2253
|
-
? '
|
|
3219
|
+
? '当前没有会变化的记录。页面打开且可见时,每 15 秒只读检查一次,新派发的任务会自动出现;切回本页会立即刷新。'
|
|
2254
3220
|
: `${liveCount > 0 ? `有 ${liveCount} 个进行中的任务;` : ''}有记录可能变化(待审或结论保存中),页面可见时每 5 秒只读刷新一次(不调用模型)。`}
|
|
2255
3221
|
</span>
|
|
2256
3222
|
<button type="button" disabled={snapshot.loading?.tasks === true} onClick={() => { void store.refreshTasks('manual'); }}>
|
|
@@ -2262,6 +3228,14 @@ function TasksPanel({ store, snapshot }) {
|
|
|
2262
3228
|
自动刷新失败({String(plan.refreshError)}),下面仍是上次读取的内容;可点“刷新”重试。
|
|
2263
3229
|
</p>
|
|
2264
3230
|
) : null}
|
|
3231
|
+
{/* A read that FAILED is stated once, here, right above what it could not
|
|
3232
|
+
refresh. It is separate from "no records": an empty list must never stand in
|
|
3233
|
+
for a refused read. */}
|
|
3234
|
+
{snapshot.tasksError !== null && snapshot.tasksError !== undefined ? (
|
|
3235
|
+
<p className="dshdg-warn" role="alert" data-dshdg-tasks-error="">
|
|
3236
|
+
{`读取任务记录失败:${describeError(snapshot.tasksError)}。下面仍是上次读取的内容,可能已经过时;可点“刷新”重试。`}
|
|
3237
|
+
</p>
|
|
3238
|
+
) : null}
|
|
2265
3239
|
{snapshot.taskDetailError !== null && snapshot.taskDetailError !== undefined ? (
|
|
2266
3240
|
<p className="dshdg-warn" role="alert">
|
|
2267
3241
|
{`打开任务详情失败:${describeError(snapshot.taskDetailError)}。可再点一次“详情”重试。`}
|
|
@@ -2270,10 +3244,8 @@ function TasksPanel({ store, snapshot }) {
|
|
|
2270
3244
|
{detail === null && snapshot.taskDetailLoading === true ? (
|
|
2271
3245
|
<p className="dshdg-hint" role="status">正在读取任务详情…</p>
|
|
2272
3246
|
) : null}
|
|
2273
|
-
{/*
|
|
2274
|
-
|
|
2275
|
-
and takes focus + scroll when it (re)appears. */}
|
|
2276
|
-
{detail === null ? null : (
|
|
3247
|
+
{/* Legacy hosts keep the list's original detail presentation. */}
|
|
3248
|
+
{detail === null || !flatOnly ? null : (
|
|
2277
3249
|
<div
|
|
2278
3250
|
ref={detailRef}
|
|
2279
3251
|
tabIndex={-1}
|
|
@@ -2283,8 +3255,11 @@ function TasksPanel({ store, snapshot }) {
|
|
|
2283
3255
|
<TaskDetail store={store} task={detail} />
|
|
2284
3256
|
</div>
|
|
2285
3257
|
)}
|
|
2286
|
-
{
|
|
2287
|
-
|
|
3258
|
+
<TaskTreePanel store={store} snapshot={snapshot} onOpen={openTask} />
|
|
3259
|
+
<PlanCreateForm store={store} snapshot={snapshot} view={treeView} />
|
|
3260
|
+
{flatOnly && tasks.length === 0 ? <p className="dshdg-faint">还没有任务记录。</p> : null}
|
|
3261
|
+
{flatOnly ? (
|
|
3262
|
+
<div className="dshdg-list" data-dshdg-flat-list="">
|
|
2288
3263
|
{tasks.map((task) => {
|
|
2289
3264
|
const progress = taskProgress(task);
|
|
2290
3265
|
// The ONE headline for this task: it already reflects a recorded review, so
|
|
@@ -2312,7 +3287,7 @@ function TasksPanel({ store, snapshot }) {
|
|
|
2312
3287
|
<button
|
|
2313
3288
|
type="button"
|
|
2314
3289
|
disabled={snapshot.taskDetailLoading === true}
|
|
2315
|
-
onClick={() =>
|
|
3290
|
+
onClick={() => openTask(task.taskId)}
|
|
2316
3291
|
>
|
|
2317
3292
|
{snapshot.taskDetailLoading === true && snapshot.taskDetail?.taskId !== task.taskId
|
|
2318
3293
|
? '读取中…'
|
|
@@ -2328,7 +3303,7 @@ function TasksPanel({ store, snapshot }) {
|
|
|
2328
3303
|
</button>
|
|
2329
3304
|
</div>
|
|
2330
3305
|
<p className="dshdg-hint">{progress.headline}</p>
|
|
2331
|
-
<TaskListNote task={task} onOpen={() =>
|
|
3306
|
+
<TaskListNote task={task} onOpen={() => openTask(task.taskId)} />
|
|
2332
3307
|
{isAwaitingPermission(task)
|
|
2333
3308
|
? <p className="dshdg-hint">{permissionSummary(task).note}</p>
|
|
2334
3309
|
: null}
|
|
@@ -2336,7 +3311,7 @@ function TasksPanel({ store, snapshot }) {
|
|
|
2336
3311
|
);
|
|
2337
3312
|
})}
|
|
2338
3313
|
</div>
|
|
2339
|
-
)}
|
|
3314
|
+
) : null}
|
|
2340
3315
|
<p className="dshdg-faint">{`状态集合:${TASK_STATES.map(taskStateLabel).join(' / ')}`}</p>
|
|
2341
3316
|
</div>
|
|
2342
3317
|
);
|
|
@@ -2478,7 +3453,6 @@ function CodexPanel({ store, snapshot }) {
|
|
|
2478
3453
|
const TABS = Object.freeze([
|
|
2479
3454
|
{ key: 'providers', label: '接口管理' },
|
|
2480
3455
|
{ key: 'execution', label: '执行设置' },
|
|
2481
|
-
{ key: 'review', label: '附加审查' },
|
|
2482
3456
|
{ key: 'tasks', label: '任务记录' },
|
|
2483
3457
|
{ key: 'codex', label: 'Codex 集成' },
|
|
2484
3458
|
]);
|
|
@@ -2561,8 +3535,11 @@ export function DelegateConfigPage(props) {
|
|
|
2561
3535
|
>
|
|
2562
3536
|
{tab === 'providers' ? <ProvidersPanel store={store} snapshot={snapshot} /> : null}
|
|
2563
3537
|
{tab === 'execution' ? <ExecutionPanel store={store} snapshot={snapshot} /> : null}
|
|
2564
|
-
{tab === '
|
|
2565
|
-
|
|
3538
|
+
{tab === 'tasks' ? (
|
|
3539
|
+
<SessionNavigation.Provider value={props.uiWorkspace || props.workspaces ? props : null}>
|
|
3540
|
+
<TasksPanel store={store} snapshot={snapshot} />
|
|
3541
|
+
</SessionNavigation.Provider>
|
|
3542
|
+
) : null}
|
|
2566
3543
|
{tab === 'codex' ? <CodexPanel store={store} snapshot={snapshot} /> : null}
|
|
2567
3544
|
</div>
|
|
2568
3545
|
|
|
@@ -2588,4 +3565,94 @@ export function DelegateConfigPage(props) {
|
|
|
2588
3565
|
}
|
|
2589
3566
|
|
|
2590
3567
|
/** Re-exported so the documented contract and tests share one name for the body document. */
|
|
2591
|
-
export { documentFromDraft, describeError, exportDocument };
|
|
3568
|
+
export { documentFromDraft, describeError, exportDocument, planCreateRequest };
|
|
3569
|
+
|
|
3570
|
+
export {
|
|
3571
|
+
MAX_CLEANUP_CHAINS,
|
|
3572
|
+
cleanupBlockerLabel,
|
|
3573
|
+
cleanupCandidates,
|
|
3574
|
+
cleanupOutcome,
|
|
3575
|
+
cleanupProjection,
|
|
3576
|
+
cleanupRequest,
|
|
3577
|
+
cleanupSelectionKey,
|
|
3578
|
+
cleanupSelectionSummary,
|
|
3579
|
+
cleanupWarningText,
|
|
3580
|
+
describeCleanupOutcome,
|
|
3581
|
+
pruneCleanupSelection,
|
|
3582
|
+
toggleCleanupSelection,
|
|
3583
|
+
withSelectionState,
|
|
3584
|
+
} from './task-cleanup.js';
|
|
3585
|
+
|
|
3586
|
+
|
|
3587
|
+
/**
|
|
3588
|
+
* Re-exported so a consumer (and `lib/client.d.ts`) reaches the native navigation through the
|
|
3589
|
+
* one module the bundle exports, rather than a second module identity.
|
|
3590
|
+
*
|
|
3591
|
+
* `registerTasksNavigation` is kept even though `apply` no longer mounts it: it is a published
|
|
3592
|
+
* helper of this bundle (and `lib/client.d.ts` declares it), and a host or a future build may
|
|
3593
|
+
* still mount the record panel itself. The task records are reached from the plugin's own
|
|
3594
|
+
* settings page (`plugins.bundle.config` → 「任务记录」), not from a sidebar row.
|
|
3595
|
+
*/
|
|
3596
|
+
export {
|
|
3597
|
+
MAIN_SLOT,
|
|
3598
|
+
SIDEBAR_PANEL_SLOT,
|
|
3599
|
+
TASKS_NAV_KEY,
|
|
3600
|
+
TASKS_NAV_LABEL,
|
|
3601
|
+
archivedSourceNote,
|
|
3602
|
+
groupTitle,
|
|
3603
|
+
knownSessionIds,
|
|
3604
|
+
locateSession,
|
|
3605
|
+
navViewModel,
|
|
3606
|
+
projectLabel,
|
|
3607
|
+
registerTasksNavigation,
|
|
3608
|
+
resolveService,
|
|
3609
|
+
resolveUiWorkspace,
|
|
3610
|
+
resolveWorkspaces,
|
|
3611
|
+
sessionPlacement,
|
|
3612
|
+
shortSessionId,
|
|
3613
|
+
taskSessionId,
|
|
3614
|
+
workspacesSnapshot,
|
|
3615
|
+
TaskbridgeNavPanel,
|
|
3616
|
+
TaskbridgeSidebarIcon,
|
|
3617
|
+
} from './sidebar.jsx';
|
|
3618
|
+
|
|
3619
|
+
/**
|
|
3620
|
+
* The TaskBridge sidebar integration and its pure view model.
|
|
3621
|
+
*
|
|
3622
|
+
* Re-exported for the same reason as the navigation above: one module identity, so a consumer
|
|
3623
|
+
* and `lib/client.d.ts` reach the same functions. `registerSessionRowMarker` is the ONLY thing
|
|
3624
|
+
* this bundle registers inside the shell's workspace area — a per-row marker in the host's own
|
|
3625
|
+
* published child slot. The parent slot stays the host's.
|
|
3626
|
+
*/
|
|
3627
|
+
export {
|
|
3628
|
+
DispatchedSessionMarker,
|
|
3629
|
+
SESSION_ROW_ACTION_ID,
|
|
3630
|
+
SESSION_ROW_ACTION_ORDER,
|
|
3631
|
+
SESSION_ROW_ACTION_SLOT,
|
|
3632
|
+
TaskbridgeGrouping,
|
|
3633
|
+
WORKSPACES_PRIORITY,
|
|
3634
|
+
WORKSPACES_SLOT,
|
|
3635
|
+
WORKSPACE_VIEWS,
|
|
3636
|
+
askConfirm,
|
|
3637
|
+
askText,
|
|
3638
|
+
dispatchProof,
|
|
3639
|
+
hostService,
|
|
3640
|
+
loadSessionMap,
|
|
3641
|
+
registerSessionRowMarker,
|
|
3642
|
+
registerWorkspacesBrowser,
|
|
3643
|
+
shortId,
|
|
3644
|
+
stableSnapshot,
|
|
3645
|
+
workspacesViewMode,
|
|
3646
|
+
} from './workspaces-browser.jsx';
|
|
3647
|
+
export {
|
|
3648
|
+
GROUP_KINDS,
|
|
3649
|
+
identityRows,
|
|
3650
|
+
isManagedRootPath,
|
|
3651
|
+
projectNameOf,
|
|
3652
|
+
readWorkspacesSnapshot,
|
|
3653
|
+
sessionIndex,
|
|
3654
|
+
sessionTitles,
|
|
3655
|
+
sourcePathKey,
|
|
3656
|
+
workspaceGroups,
|
|
3657
|
+
workspaceItems,
|
|
3658
|
+
} from './workspace-groups.js';
|