dsh-taskbridge 1.6.0 → 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.
Files changed (66) hide show
  1. package/CHANGELOG.md +10 -1
  2. package/README.md +41 -41
  3. package/THIRD_PARTY_NOTICES.txt +23 -0
  4. package/codex/dsh-taskbridge.toml +140 -71
  5. package/docs/INTRODUCTION.md +44 -22
  6. package/docs/INTRODUCTION.zh.md +32 -26
  7. package/docs/codex-integration.md +90 -10
  8. package/docs/contracts-stage-b.md +4 -4
  9. package/docs/conversation-placement.md +25 -7
  10. package/docs/plugin-market.md +1 -1
  11. package/docs/releases/1.7.0.zh.md +11 -0
  12. package/docs/runtime-compatibility.md +4 -11
  13. package/docs/silent-wait.md +69 -31
  14. package/docs/taskbridge-upgrade.md +1 -1
  15. package/docs/worker-permissions.md +4 -14
  16. package/docs/workspace-grouping.md +126 -0
  17. package/lib/client.d.ts +365 -3
  18. package/lib/client.js +260 -5
  19. package/locale/en.json +1 -1
  20. package/locale/zh.json +1 -1
  21. package/package.json +7 -19
  22. package/src/client/api.js +550 -90
  23. package/src/client/index.jsx +699 -307
  24. package/src/client/sidebar.jsx +6 -5
  25. package/src/client/styles.js +251 -0
  26. package/src/client/task-cleanup.js +304 -0
  27. package/src/client/task-records-table.jsx +217 -0
  28. package/src/client/task-view.js +226 -10
  29. package/src/client/workspace-groups.js +482 -0
  30. package/src/client/workspaces-browser.jsx +770 -0
  31. package/src/codex/agent-ownership.js +270 -0
  32. package/src/codex/installer.js +525 -35
  33. package/src/codex/seam.js +5 -0
  34. package/src/config/defaults.js +63 -17
  35. package/src/config/settings.js +60 -62
  36. package/src/config/validate.js +126 -71
  37. package/src/http/respond.js +8 -0
  38. package/src/http/user-plane.js +197 -2
  39. package/src/index.js +50 -42
  40. package/src/jobs/activity.js +968 -78
  41. package/src/jobs/engine.js +784 -230
  42. package/src/jobs/history.js +188 -12
  43. package/src/jobs/plan-store.js +5 -0
  44. package/src/jobs/record-cleanup.js +196 -0
  45. package/src/jobs/task-tree.js +5 -3
  46. package/src/jobs/title.js +129 -12
  47. package/src/mcp/server.js +16 -8
  48. package/src/mcp/wait.js +64 -5
  49. package/src/runtime/agent-runner.js +53 -15
  50. package/src/runtime/worker-prompt.js +53 -0
  51. package/src/workspace/locks.js +288 -167
  52. package/docs/releases/1.4.0-token-benchmark.zh.md +0 -40
  53. package/docs/releases/1.4.0.zh.md +0 -54
  54. package/docs/releases/1.4.1.zh.md +0 -59
  55. package/docs/releases/1.4.2.zh.md +0 -23
  56. package/docs/releases/1.5.0-token-benchmark.zh.md +0 -73
  57. package/docs/releases/1.5.0.zh.md +0 -51
  58. package/docs/releases/1.5.1.zh.md +0 -70
  59. package/docs/releases/1.5.2.zh.md +0 -30
  60. package/docs/releases/1.5.3-test.1.zh.md +0 -28
  61. package/docs/releases/1.5.3-test.2.zh.md +0 -24
  62. package/docs/releases/1.5.3.zh.md +0 -33
  63. package/docs/releases/1.5.4.zh.md +0 -25
  64. package/src/review/preset.js +0 -868
  65. package/src/review/prompts.js +0 -145
  66. package/src/review/reviewer.js +0 -933
@@ -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,
@@ -86,17 +86,21 @@ import {
86
86
  grantState,
87
87
  isAwaitingPermission,
88
88
  isCancellable,
89
+ executionOf,
90
+ AGENT_TEAMS_ORIGIN_LABELS,
89
91
  hasLiveTasks,
90
92
  formatDuration,
91
93
  hostReviewLine,
92
94
  RECORD_REFRESH_INTERVAL_MS,
93
95
  recordRefreshPlan,
96
+ startRecordsReadLoop,
94
97
  reviewNotePreview,
95
98
  hasChangingRecords,
96
99
  isLiveTask,
97
100
  minutesToSeconds,
98
101
  monitoringDraftOf,
99
102
  monitoringOf,
103
+ monitoringText,
100
104
  pendingPermission,
101
105
  permissionSummary,
102
106
  planCreateRequest,
@@ -114,8 +118,21 @@ import {
114
118
  WAIT_REASON_LABELS,
115
119
  } from './api.js';
116
120
  import { injectStyles } from './styles.js';
117
- import { registerTasksNavigation, resolveUiWorkspace, resolveWorkspaces } from './sidebar.jsx';
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';
118
133
  import { projectTaskView } from './task-view.js';
134
+ import { TaskRecordsTable } from './task-records-table.jsx';
135
+ import { registerWorkspacesBrowser } from './workspaces-browser.jsx';
119
136
 
120
137
  /** Plugins-manager config slot this page occupies. */
121
138
  export const PLUGIN_CONFIG_SLOT = 'plugins.bundle.config';
@@ -130,6 +147,8 @@ export const PLUGIN_BUNDLE_KEY = 'dsh-taskbridge';
130
147
  /** Required client services: slot registration only. */
131
148
  export const inject = ['slots'];
132
149
 
150
+ const SessionNavigation = createContext(null);
151
+
133
152
  /**
134
153
  * Register the bundle configuration page on a client context.
135
154
  *
@@ -141,8 +160,8 @@ export const inject = ['slots'];
141
160
  * @returns {Function} disposer releasing the registration.
142
161
  */
143
162
  export function registerBundleConfiguration(ctx, options) {
144
- const store = options.store;
145
- const injectFace = () => ({ store });
163
+ const { store, uiWorkspace, workspaces } = options;
164
+ const injectFace = () => ({ store, uiWorkspace, workspaces });
146
165
  return ctx.slots.inject(PLUGIN_CONFIG_SLOT, () => ctx.slots.register({
147
166
  name: PLUGIN_CONFIG_SLOT,
148
167
  key: PLUGIN_BUNDLE_KEY,
@@ -156,14 +175,55 @@ export function registerBundleConfiguration(ctx, options) {
156
175
  */
157
176
  export function apply(ctx) {
158
177
  ctx.effect(() => injectStyles(globalThis.document), 'dsh-delegate: settings styles');
159
- const store = createStore({ api: createApi() });
178
+ const store = createStore({ api: createApi(), cleanup: cleanupProjection() });
160
179
  ctx.effect(() => () => store.dispose(), 'dsh-delegate: settings store');
161
- ctx.effect(() => registerBundleConfiguration(ctx, { store }), 'dsh-delegate: bundle configuration');
162
- ctx.effect(() => registerTasksNavigation(ctx, {
180
+ const navigation = {
163
181
  store,
164
182
  uiWorkspace: () => resolveUiWorkspace(ctx),
165
183
  workspaces: () => resolveWorkspaces(ctx),
166
- }), 'dsh-delegate: sidebar navigation');
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;
167
227
  }
168
228
 
169
229
  // ---------------------------------------------------------------------------
@@ -669,9 +729,7 @@ function ProviderEditor({ provider, store, snapshot, index }) {
669
729
  const target = draft.providers.find((entry) => entry.id === providerId);
670
730
  if (target === undefined) return;
671
731
  target.id = nextId;
672
- for (const block of [draft.worker, draft.review]) {
673
- if (block?.providerId === providerId) block.providerId = nextId;
674
- }
732
+ if (draft.worker?.providerId === providerId) draft.worker.providerId = nextId;
675
733
  });
676
734
  }}
677
735
  />
@@ -846,13 +904,10 @@ function ProviderEditor({ provider, store, snapshot, index }) {
846
904
  // A selection pointing at the removed model would be
847
905
  // unroutable; clear it here so the operator sees the
848
906
  // consequence instead of saving an invalid pair.
849
- if (removed !== undefined) {
850
- for (const block of [draft.worker, draft.review]) {
851
- if (block?.providerId === providerId && block?.model === removed.id) {
852
- block.model = null;
853
- block.reasoningEffort = null;
854
- }
855
- }
907
+ if (removed !== undefined && draft.worker?.providerId === providerId
908
+ && draft.worker.model === removed.id) {
909
+ draft.worker.model = null;
910
+ draft.worker.reasoningEffort = null;
856
911
  }
857
912
  });
858
913
  }}
@@ -959,9 +1014,9 @@ function ProvidersPanel({ store, snapshot }) {
959
1014
 
960
1015
  function isUsed(id) {
961
1016
  const draft = snapshot.draft ?? {};
962
- const selections = [draft.worker, draft.review, ...(draft.presets ?? []).flatMap((preset) => [preset.worker, preset.review])];
1017
+ const selections = [draft.worker, ...(draft.presets ?? []).map((preset) => preset.worker)];
963
1018
  for (const block of Object.values(draft.projectOverrides ?? {})) {
964
- selections.push(block?.worker, block?.review);
1019
+ selections.push(block?.worker);
965
1020
  }
966
1021
  return selections.some((selection) => selection?.providerId === id);
967
1022
  }
@@ -1127,7 +1182,6 @@ function LegacyProvidersPanel({ store, snapshot }) {
1127
1182
  */
1128
1183
  function EffectiveSummary({ label, effective, note }) {
1129
1184
  const worker = effective?.worker ?? {};
1130
- const review = effective?.review ?? {};
1131
1185
  return (
1132
1186
  <div className="dshdg-card">
1133
1187
  <h4>{label}</h4>
@@ -1138,25 +1192,26 @@ function EffectiveSummary({ label, effective, note }) {
1138
1192
  <dd className="dshdg-mono">{worker.model ?? '(未配置)'}</dd>
1139
1193
  <dt>执行推理强度</dt>
1140
1194
  <dd className="dshdg-mono">{worker.reasoningEffort ?? '(不指定)'}</dd>
1141
- <dt>超时</dt>
1142
- <dd>{worker.timeoutSeconds === undefined ? '—' : `${worker.timeoutSeconds} 秒`}</dd>
1195
+ <dt>执行时长</dt>
1196
+ <dd>
1197
+ {effective?.worker?.executionTimeoutSeconds === null || effective?.worker?.executionTimeoutSeconds === undefined
1198
+ ? '不设上限(只由你主动取消)'
1199
+ : `本任务显式上限 ${formatDuration(effective.worker.executionTimeoutSeconds * 1000)}`}
1200
+ </dd>
1143
1201
  <dt>最大并发</dt>
1144
1202
  <dd>{worker.maxParallelism ?? '—'}</dd>
1145
1203
  <dt>工作区隔离</dt>
1146
1204
  <dd>{ISOLATION_LABELS[worker.isolation] ?? worker.isolation ?? '—'}</dd>
1147
1205
  <dt>对话</dt>
1148
1206
  <dd>{CONVERSATION_POLICY_LABEL}</dd>
1149
- <dt>附加审查</dt>
1150
- <dd>
1151
- {review.enabled === true
1152
- ? `开启 · ${review.providerId ?? '(未配置)'} / ${review.model ?? '(未配置)'} / ${review.reasoningEffort ?? '不指定'}`
1153
- : '关闭'}
1154
- </dd>
1155
1207
  <dt>静默监控</dt>
1156
1208
  <dd>
1157
1209
  {effective?.monitoring === null || effective?.monitoring === undefined
1158
1210
  ? '未采集到'
1159
- : `自检 ${formatDuration(effective.monitoring.selfCheckSeconds * 1000)} · 提醒 ${formatDuration(effective.monitoring.attentionSeconds * 1000)}`}
1211
+ : [
1212
+ `自检 ${monitoringText(effective.monitoring.selfCheckSeconds)}`,
1213
+ `运行进度检查 ${monitoringText(effective.monitoring.attentionSeconds)}`,
1214
+ ].join(' · ')}
1160
1215
  </dd>
1161
1216
  </dl>
1162
1217
  {note === undefined ? null : <p className="dshdg-hint">{note}</p>}
@@ -1189,7 +1244,7 @@ function PresetsCard({ store, snapshot }) {
1189
1244
  <div className="dshdg-card">
1190
1245
  <h4>预设、导出与项目覆盖</h4>
1191
1246
  <p className="dshdg-hint">
1192
- 预设只包含执行/审查组合;导出内容全部是非敏感配置,任何密钥都不会出现(密钥只存在宿主的凭据存储里)。
1247
+ 预设保存执行设置,导出的配置不含密钥。
1193
1248
  正在运行的任务保留它自己的生效快照,之后的修改不会改写历史。
1194
1249
  </p>
1195
1250
 
@@ -1215,18 +1270,15 @@ function PresetsCard({ store, snapshot }) {
1215
1270
  store.editDraft((current) => {
1216
1271
  const existing = current.presets.find((entry) => entry.id === presetId);
1217
1272
  const snapshotWorker = clone(current.worker);
1218
- const snapshotReview = current.review?.enabled === true ? clone(current.review) : null;
1219
1273
  if (existing === undefined) {
1220
1274
  current.presets.push({
1221
1275
  id: presetId,
1222
1276
  name: presetName === '' ? presetId : presetName,
1223
1277
  worker: snapshotWorker,
1224
- ...(snapshotReview === null ? {} : { review: snapshotReview }),
1225
1278
  });
1226
1279
  } else {
1227
1280
  existing.name = presetName === '' ? existing.name : presetName;
1228
1281
  existing.worker = snapshotWorker;
1229
- existing.review = snapshotReview;
1230
1282
  }
1231
1283
  });
1232
1284
  setPresetId('');
@@ -1250,7 +1302,6 @@ function PresetsCard({ store, snapshot }) {
1250
1302
  onClick={() => {
1251
1303
  store.editDraft((current) => {
1252
1304
  if (preset.worker !== null && preset.worker !== undefined) current.worker = { ...preset.worker };
1253
- if (preset.review !== null && preset.review !== undefined) current.review = { ...preset.review };
1254
1305
  });
1255
1306
  }}
1256
1307
  >
@@ -1329,7 +1380,6 @@ function PresetsCard({ store, snapshot }) {
1329
1380
  store.editDraft((current) => {
1330
1381
  current.providers = next.providers;
1331
1382
  current.worker = next.worker;
1332
- current.review = next.review;
1333
1383
  current.authorization = next.authorization;
1334
1384
  current.projectOverrides = next.projectOverrides;
1335
1385
  current.presets = next.presets;
@@ -1400,9 +1450,9 @@ function PresetsCard({ store, snapshot }) {
1400
1450
  />
1401
1451
  </Field>
1402
1452
  <Field
1403
- label={`覆盖内容(JSON,仅允许 worker / review)`}
1453
+ label="执行覆盖内容(JSON)"
1404
1454
  htmlFor="dshdg-override-json"
1405
- hint={'例如 {"worker":{"model":"deepseek-chat","reasoningEffort":"high"},"review":{"enabled":false}}'}
1455
+ hint={'例如 {"worker":{"model":"deepseek-chat","reasoningEffort":"high"}}'}
1406
1456
  >
1407
1457
  <textarea
1408
1458
  id="dshdg-override-json"
@@ -1423,7 +1473,7 @@ function PresetsCard({ store, snapshot }) {
1423
1473
  setOverrideError(`无法解析:${String(error?.message ?? error).slice(0, 160)}`);
1424
1474
  return;
1425
1475
  }
1426
- const unknown = Object.keys(parsed).filter((key) => key !== 'worker' && key !== 'review');
1476
+ const unknown = Object.keys(parsed).filter((key) => key !== 'worker');
1427
1477
  if (unknown.length > 0) {
1428
1478
  setOverrideError(`不支持的字段:${unknown.join('、')}`);
1429
1479
  return;
@@ -1455,18 +1505,24 @@ function PresetsCard({ store, snapshot }) {
1455
1505
  }
1456
1506
 
1457
1507
  /**
1458
- * Advanced monitoring controls for a running task's silence.
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.
1459
1514
  *
1460
1515
  * What this card deliberately does NOT do: it does not submit work, does not read a
1461
- * task, does not call a model, and does not create a monitoring process of its own.
1462
- * It edits two numbers and, on the operator's click, sends them to the one narrow
1463
- * authenticated route. Everything it says about the behaviour is a statement about
1464
- * the engine, not a control here.
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.
1465
1520
  *
1466
1521
  * Units: the operator thinks in minutes, the document stores whole seconds. Each
1467
- * field converts on the way in and out (`minutesToSeconds` / `secondsToMinutes`), so a
1468
- * stored value of 300 s shows as 5 and a value of 90 s shows as 1.5 rather than being
1469
- * 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`.
1470
1526
  * @param {object} props - `store`, `snapshot`.
1471
1527
  * @returns {object} the monitoring card.
1472
1528
  */
@@ -1483,11 +1539,10 @@ function MonitoringCard({ store, snapshot }) {
1483
1539
  || raw.repeatFailureThreshold !== saved.repeatFailureThreshold;
1484
1540
 
1485
1541
  /**
1486
- * Write one field, converting minutes back to the stored unit.
1487
- *
1488
- * The block is spread from the RAW draft, not from `monitoringOf`: normalizing here
1489
- * would rewrite the operator's other half-typed fields (for example a cleared count)
1490
- * 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.
1491
1546
  * @param {'selfCheckSeconds' | 'attentionSeconds'} field - target field.
1492
1547
  * @param {unknown} rawMinutes - operator input, in minutes.
1493
1548
  * @returns {void}
@@ -1513,52 +1568,73 @@ function MonitoringCard({ store, snapshot }) {
1513
1568
  });
1514
1569
  };
1515
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
+
1516
1605
  return (
1517
1606
  <div className="dshdg-card" data-dshdg-monitoring="">
1518
- <h4>进阶:静默监控间隔</h4>
1607
+ <h4>进度与静默监控</h4>
1519
1608
  <p className="dshdg-hint">
1520
- 任务长时间没有新输出时,插件自己会看一眼执行器还在不在(程序自检),再过一段时间才提醒你。
1521
- <strong>这些检查完全在本机进行,不会调用任何大模型,也不消耗 token。</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> 即关闭对应提醒,两项可以分别关闭。
1522
1618
  </p>
1523
1619
  <div className="dshdg-grid">
1524
- <Field
1620
+ <DurationField
1621
+ id="dshdg-monitoring-selfcheck"
1525
1622
  label="程序自检间隔(分钟)"
1526
- htmlFor="dshdg-monitoring-selfcheck"
1527
- hint={`${LIMITS.selfCheckSecondsMin / 60}–${LIMITS.selfCheckSecondsMax / 60} 分钟;存成整秒(当前 ${raw.selfCheckSeconds === '' ? '未填' : `${raw.selfCheckSeconds} 秒`})`}
1528
- >
1529
- <input
1530
- id="dshdg-monitoring-selfcheck"
1531
- type="number"
1532
- inputMode="decimal"
1533
- min={LIMITS.selfCheckSecondsMin / 60}
1534
- max={LIMITS.selfCheckSecondsMax / 60}
1535
- step={0.5}
1536
- value={String(Number.isFinite(secondsToMinutes(raw.selfCheckSeconds)) ? secondsToMinutes(raw.selfCheckSeconds) : '')}
1537
- onChange={(event) => {
1538
- const value = event.target.value;
1539
- edit('selfCheckSeconds', value === '' ? '' : value);
1540
- }}
1541
- />
1542
- </Field>
1543
- <Field
1544
- label="提醒你的间隔(分钟)"
1545
- htmlFor="dshdg-monitoring-attention"
1546
- hint={`${LIMITS.attentionSecondsMin / 60}–${LIMITS.attentionSecondsMax / 60} 分钟,且必须大于自检间隔;存成整秒(当前 ${raw.attentionSeconds === '' ? '未填' : `${raw.attentionSeconds} 秒`})`}
1547
- >
1548
- <input
1549
- id="dshdg-monitoring-attention"
1550
- type="number"
1551
- inputMode="decimal"
1552
- min={LIMITS.attentionSecondsMin / 60}
1553
- max={LIMITS.attentionSecondsMax / 60}
1554
- step={0.5}
1555
- value={String(Number.isFinite(secondsToMinutes(raw.attentionSeconds)) ? secondsToMinutes(raw.attentionSeconds) : '')}
1556
- onChange={(event) => {
1557
- const value = event.target.value;
1558
- edit('attentionSeconds', value === '' ? '' : value);
1559
- }}
1560
- />
1561
- </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
+ />
1562
1638
  <Field
1563
1639
  label="重复失败提醒(次)"
1564
1640
  htmlFor="dshdg-monitoring-repeat"
@@ -1578,17 +1654,18 @@ function MonitoringCard({ store, snapshot }) {
1578
1654
  </div>
1579
1655
  {problems.length === 0 ? null : <p className="dshdg-fail">{problems.join(';')}</p>}
1580
1656
  <ul className="dshdg-hint">
1581
- <li>「没有新进展」本身不等于失败:插件不会因为安静、也不会因为单个工具跑得久就判定任务失败。</li>
1582
- <li>只有确实没有进展、并且超过「提醒你的间隔」之后,才会把这件事报告给派工方。</li>
1583
- <li>重复失败提醒与上面两个间隔<strong>互相独立</strong>:它数的是同一操作连续失败了几次,而不是安静了多久,所以正在忙碌地反复失败也会被提醒。它只提醒一次,不会自动取消任务、更换模型或改动超时。</li>
1657
+ <li>「没有新成果回传」本身不等于失败:插件不会因为安静、也不会因为单个工具跑得久就判定任务失败。</li>
1658
+ <li>只有<strong>连续</strong>没有新成果回传、并且超过「运行进度检查」之后,才会把这件事报告给派工方核对一次目标;同一段间隔最多报告一次,真实回传新成果后会重新计时。</li>
1659
+ <li>提醒不依赖任务总运行时长:跑上几小时但一直在回传新成果,就不会有提醒;也没有「总执行超时」这种按总时长中止的设置。</li>
1660
+ <li>重复失败提醒与上面两个间隔<strong>互相独立</strong>:它数的是同一操作连续失败了几次,而不是多久没有回传,所以正在忙碌地反复失败也会被提醒。它只提醒一次,不会自动取消任务或更换模型。</li>
1584
1661
  <li>修改只影响<strong>之后新提交</strong>的任务;已经运行的任务保留它开始时的那份间隔快照。</li>
1585
- <li>程序自检只读取本机已有的事实(任务是否还在、当前阶段、有没有待决定的调用、正在跑哪个工具),不读取代码差异,也不会读取你的文件内容。</li>
1662
+ <li>程序自检只读取本机已有的事实(任务是否还在、当前阶段、有没有待决定的调用、正在跑哪个工具,以及"未回传多久"和"DSH 正在做什么"),不读取代码差异,也不会读取你的文件内容;即使没有人正在等待,任务详情也能看到它已做的自检。读到自检结论只是读诊断,不会重置运行进度检查的计时。</li>
1586
1663
  </ul>
1587
1664
  <div className="dshdg-row" data-dshdg-monitoring-status="">
1588
1665
  <span className="dshdg-hint" role="status" aria-live="polite">
1589
1666
  {dirty
1590
1667
  ? '与已保存的值不同,正在自动保存(与整份设置走同一个串行保存队列)。'
1591
- : `已保存:自检 ${saved.selfCheckSeconds} 秒,提醒 ${saved.attentionSeconds} 秒。`}
1668
+ : `已保存:自检 ${saved.selfCheckSeconds} 秒,运行进度检查 ${saved.attentionSeconds} 秒。`}
1592
1669
  </span>
1593
1670
  </div>
1594
1671
  <p className="dshdg-hint">
@@ -1598,6 +1675,93 @@ function MonitoringCard({ store, snapshot }) {
1598
1675
  );
1599
1676
  }
1600
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
+
1601
1765
  /** @param {object} props @returns {object} the execution settings panel. */
1602
1766
  function ExecutionPanel({ store, snapshot }) {
1603
1767
  const draft = snapshot.draft;
@@ -1628,24 +1792,13 @@ function ExecutionPanel({ store, snapshot }) {
1628
1792
  }}
1629
1793
  />
1630
1794
  <div className="dshdg-grid">
1631
- <IntegerField
1632
- id="dshdg-worker-timeout"
1633
- label="超时(秒)"
1634
- value={worker.timeoutSeconds}
1635
- min={LIMITS.timeoutSecondsMin}
1636
- max={LIMITS.timeoutSecondsMax}
1637
- hint={`${LIMITS.timeoutSecondsMin}–${LIMITS.timeoutSecondsMax}`}
1638
- onChange={(value) => {
1639
- store.editDraft((current) => { current.worker.timeoutSeconds = value; });
1640
- }}
1641
- />
1642
1795
  <IntegerField
1643
1796
  id="dshdg-worker-parallelism"
1644
1797
  label="最大并发"
1645
1798
  value={worker.maxParallelism}
1646
1799
  min={LIMITS.maxParallelismMin}
1647
1800
  max={LIMITS.maxParallelismMax}
1648
- hint={`${LIMITS.maxParallelismMin}–${LIMITS.maxParallelismMax},超出会被拒绝而不是自动调整`}
1801
+ hint={`${LIMITS.maxParallelismMin}–${LIMITS.maxParallelismMax},超出会被拒绝而不是自动调整。限制的是本插件同时接纳的派工数:按到达顺序争取名额,超出会被拒绝而不是排队;准备中、运行中和等待授权的任务都算占用,执行器确认结束后才让位。每个独立工作包各占一个名额;同一来源的隔离任务可开成独立会话并行,共享目录一次只跑一个;智能体协作的子智能体只在会话内部,不计入名额。`}
1649
1802
  onChange={(value) => {
1650
1803
  store.editDraft((current) => { current.worker.maxParallelism = value; });
1651
1804
  }}
@@ -1675,6 +1828,11 @@ function ExecutionPanel({ store, snapshot }) {
1675
1828
  </p>
1676
1829
  </Field>
1677
1830
  </div>
1831
+ <p className="dshdg-hint">
1832
+ 任务<strong>没有总执行时长上限</strong>:不会因为跑得久被自动中止,只有你主动取消才会停止。
1833
+ 长时间没有进展由下面的「进度与静默监控」提醒你判断,提醒本身不会取消、重启或重新提交任务。
1834
+ 旧版本存下的「超时」值仍会被读取,但不再限制新任务。
1835
+ </p>
1678
1836
  <p className="dshdg-hint">
1679
1837
  不会自动回退到别的模型,也不会隐式使用 Harness 默认模型:选中的组合不可路由时任务直接拒绝。
1680
1838
  </p>
@@ -1693,6 +1851,7 @@ function ExecutionPanel({ store, snapshot }) {
1693
1851
  />
1694
1852
  )}
1695
1853
  <MonitoringCard store={store} snapshot={snapshot} />
1854
+ <AgentTeamsCard store={store} snapshot={snapshot} />
1696
1855
  {served === null ? (
1697
1856
  <p className="dshdg-faint">宿主尚未回报实际生效值(模型目录不可用或尚未加载)。</p>
1698
1857
  ) : (
@@ -1708,78 +1867,53 @@ function ExecutionPanel({ store, snapshot }) {
1708
1867
  }
1709
1868
 
1710
1869
  // ---------------------------------------------------------------------------
1711
- // Additional review
1870
+ // Task records
1712
1871
  // ---------------------------------------------------------------------------
1713
1872
 
1714
- /** @param {object} props @returns {object} the review panel. */
1715
- function ReviewPanel({ store, snapshot }) {
1716
- const draft = snapshot.draft;
1717
- const providers = draft?.providers ?? [];
1718
- const review = draft?.review ?? { enabled: false };
1719
- const enabled = review.enabled === true;
1720
- const worker = draft?.worker ?? {};
1721
- const sameRoute = enabled
1722
- && review.providerId === (worker.providerId ?? null)
1723
- && review.model === (worker.model ?? null);
1724
- if (draft === null) return <p className="dshdg-faint">正在读取设置…</p>;
1725
- return (
1726
- <div className="dshdg-panel">
1727
- <div className="dshdg-card">
1728
- <div className="dshdg-row">
1729
- <label htmlFor="dshdg-review-enabled">
1730
- <input
1731
- id="dshdg-review-enabled"
1732
- type="checkbox"
1733
- checked={enabled}
1734
- onChange={(event) => {
1735
- // A SWITCH is one discrete decision: save it at once.
1736
- store.editDraft((current) => { current.review.enabled = event.target.checked; }, { immediate: true });
1737
- }}
1738
- />
1739
- {' '}启用附加模型审查(默认关闭)
1740
- </label>
1741
- <span className="dshdg-spacer" />
1742
- <Badge tone={enabled ? 'on' : 'off'}>{enabled ? '已启用' : '关闭'}</Badge>
1743
- </div>
1744
- <p className="dshdg-muted">
1745
- 附加审查是独立的只读检查:它读交付的 diff 与证据,给出建议,但<strong>不能</strong>代替宿主验收、不能修改文件、
1746
- 也不会触发自动修复循环。它和本机调用开关相互独立。
1747
- </p>
1748
- {sameRoute ? (
1749
- <p className="dshdg-fail">
1750
- 审查与执行的提供方/模型相同,独立性问题无法保证;建议换一个模型。宿主可能会拒绝这种组合。
1751
- </p>
1752
- ) : null}
1753
- </div>
1754
- {enabled ? (
1755
- <SelectionFields
1756
- providers={providers}
1757
- idPrefix="dshdg-review"
1758
- value={{
1759
- providerId: review.providerId ?? null,
1760
- model: review.model ?? null,
1761
- reasoningEffort: review.reasoningEffort ?? null,
1762
- }}
1763
- onChange={(next) => {
1764
- // Review provider/model/effort are SELECTS: saved at once.
1765
- store.editDraft((current) => {
1766
- current.review.providerId = next.providerId;
1767
- current.review.model = next.model;
1768
- if ('reasoningEffort' in next) current.review.reasoningEffort = next.reasoningEffort;
1769
- }, { immediate: true });
1770
- }}
1771
- />
1772
- ) : (
1773
- <p className="dshdg-faint">关闭时不创建审查代理,也不发出任何审查请求。</p>
1774
- )}
1775
- </div>
1776
- );
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}),该任务不会在旧模式下继续执行。`;
1777
1915
  }
1778
1916
 
1779
- // ---------------------------------------------------------------------------
1780
- // Task records
1781
- // ---------------------------------------------------------------------------
1782
-
1783
1917
  /**
1784
1918
  * The full recorded review note of one task, expandable and copyable.
1785
1919
  *
@@ -1859,6 +1993,40 @@ function ReviewNoteDetail({ task, store }) {
1859
1993
  );
1860
1994
  }
1861
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
+
1862
2030
  /**
1863
2031
  * One task's details: effective config, diff, evidence, usage, review outcome.
1864
2032
  * @param {object} props - `store`, `task`.
@@ -1875,8 +2043,11 @@ function TaskDetail({ store, task }) {
1875
2043
  // `view()` freezes the configuration that actually ran; a later settings edit
1876
2044
  // does not retroactively change what a finished task reports.
1877
2045
  const worker = task.effective?.worker ?? {};
1878
- const review = task.review ?? null;
1879
- const reviewState = review === null ? 'not_run' : (review.state ?? 'not_run');
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';
1880
2051
  const diff = task.diff ?? null;
1881
2052
  const execution = task.execution ?? null;
1882
2053
  const error = task.error ?? execution?.error ?? null;
@@ -1905,6 +2076,7 @@ function TaskDetail({ store, task }) {
1905
2076
  </button>
1906
2077
  </div>
1907
2078
  <p className="dshdg-muted">{outcome.note}</p>
2079
+ <OpenTaskSession key={task.taskId} store={store} taskId={task.taskId} />
1908
2080
 
1909
2081
  <div className="dshdg-card" data-dshdg-task-progress="">
1910
2082
  <h4>进展</h4>
@@ -1966,19 +2138,16 @@ function TaskDetail({ store, task }) {
1966
2138
  </dd>
1967
2139
  <dt>重复失败提醒</dt>
1968
2140
  <dd>{repeatFailureLine(activity)}</dd>
2141
+ <dt>智能体协作</dt>
2142
+ <dd data-dshdg-task-team="">
2143
+ {teamLine(task)}
2144
+ </dd>
1969
2145
  <dt>创建</dt>
1970
2146
  <dd>{formatTime(task.createdAt)}</dd>
1971
2147
  <dt>结束</dt>
1972
2148
  <dd>{formatTime(task.endedAt)}</dd>
1973
2149
  <dt>用量</dt>
1974
2150
  <dd>{execution?.usage === null || execution?.usage === undefined ? '不可用' : boundedText(execution.usage, 600)}</dd>
1975
- <dt>附加审查</dt>
1976
- <dd>
1977
- {REVIEW_STATE_LABELS[reviewState] ?? reviewState}
1978
- {review?.verdict === null || review?.verdict === undefined
1979
- ? ''
1980
- : ` · ${REVIEW_VERDICT_LABELS[review.verdict] ?? review.verdict}`}
1981
- </dd>
1982
2151
  <dt>宿主验收</dt>
1983
2152
  <dd>{hostReviewLine(task, formatTime)}</dd>
1984
2153
  <dt>完整审查意见</dt>
@@ -2007,12 +2176,13 @@ function TaskDetail({ store, task }) {
2007
2176
  </>
2008
2177
  )}
2009
2178
 
2010
- {review?.text === undefined || review?.text === null || review.text === '' ? null : (
2011
- <>
2012
- <h4>审查发现</h4>
2013
- <pre className="dshdg-pre">{boundedText(review.text, 8000)}</pre>
2014
- </>
2015
- )}
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}
2016
2186
 
2017
2187
  <h4>本次调用授权</h4>
2018
2188
  <p className={isAwaitingPermission(task) ? 'dshdg-hint' : 'dshdg-faint'}>{permission.note}</p>
@@ -2062,102 +2232,32 @@ function TaskDetail({ store, task }) {
2062
2232
  }
2063
2233
 
2064
2234
  /** @param {object} props @returns {object} the task records panel. */
2065
- /**
2066
- * Bounded, program-driven task refresh.
2067
- *
2068
- * Every condition here exists to keep a *visible page* from doing work on its own:
2069
- *
2070
- * * it runs ONLY while the tasks tab is mounted (the effect lives in `TasksPanel`),
2071
- * so switching tabs or unmounting clears the timer;
2072
- * * it runs while any RECORD may still change — a running task, a task awaiting host
2073
- * review, or a review that is still being written — not only while something is
2074
- * executing. A finished run's conclusion is written by the commander, and a page that
2075
- * stopped polling when execution ended would never show it;
2076
- * * it stops once every visible record is settled (the conclusion is durable);
2077
- * * it skips a hidden document and registers a `visibilitychange` listener so returning
2078
- * to the tab reads immediately instead of waiting out the interval;
2079
- * * it never overlaps: a refresh in flight suppresses the next tick;
2080
- * * it is a pure read of the task list — no model call, no task action, no settings
2081
- * write — so it cannot disturb an unsaved draft or the selected task;
2082
- * * a failed refresh keeps the records already shown and states the failure.
2083
- * @param {object} props - `store`, `snapshot`, `intervalMs`.
2084
- * @returns {object | null} nothing (side effects only).
2085
- */
2086
- function useTaskAutoRefresh({ store, snapshot, intervalMs = RECORD_REFRESH_INTERVAL_MS }) {
2087
- 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({
2088
2239
  tasks: snapshot.tasks,
2089
2240
  selectedTask: snapshot.taskDetail,
2090
- visible: globalThis.document?.hidden !== true,
2091
2241
  loading: snapshot.loading?.tasks === true,
2242
+ hydrated: snapshot.tasksLoaded === true,
2092
2243
  });
2093
- const changing = hasChangingRecords([
2094
- ...(Array.isArray(snapshot.tasks) ? snapshot.tasks : []),
2095
- ...(snapshot.taskDetail === null || snapshot.taskDetail === undefined ? [] : [snapshot.taskDetail]),
2096
- ]);
2097
- // Read through a ref so the effect does not restart on every store revision: a
2098
- // restarted effect would reset the timer constantly and effectively poll far
2099
- // faster than the interval.
2100
- const changingRef = useRef(changing);
2101
- 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
+ };
2102
2250
  const [refreshError, setRefreshError] = useState(null);
2103
2251
 
2104
2252
  useEffect(() => {
2105
- if (!changing) return undefined;
2106
- let timer = null;
2107
- let disposed = false;
2108
- let inFlight = false;
2109
-
2110
- const schedule = () => {
2111
- if (disposed) return;
2112
- if (timer !== null) clearTimeout(timer);
2113
- timer = setTimeout(tick, intervalMs);
2114
- timer.unref?.();
2115
- };
2116
-
2117
- const read = () => {
2118
- if (inFlight) return;
2119
- inFlight = true;
2120
- setRefreshError(null);
2121
- void store.refreshTasks('auto').then((result) => {
2122
- // A failed read keeps the records already shown (the store does not clear them) and
2123
- // is stated as a refresh problem — never as a lost task or a failed execution.
2124
- if (result?.ok === false) setRefreshError(describeError(result.error));
2125
- }).finally(() => {
2126
- inFlight = false;
2127
- schedule();
2128
- });
2129
- };
2130
-
2131
- const tick = () => {
2132
- timer = null;
2133
- if (disposed) return;
2134
- // A hidden tab is not watching anything: skip the read entirely, and let the
2135
- // visibility listener below schedule the next one when it comes back.
2136
- if (globalThis.document?.hidden === true) return;
2137
- if (!changingRef.current) return;
2138
- read();
2139
- };
2140
-
2141
- const onVisibility = () => {
2142
- if (globalThis.document?.hidden === true) return;
2143
- if (!changingRef.current) return;
2144
- if (timer !== null) clearTimeout(timer);
2145
- timer = null;
2146
- // Coming back to the page reads once IMMEDIATELY: the operator must not wait out
2147
- // an interval to see what changed while the tab was hidden.
2148
- read();
2149
- };
2150
-
2151
- schedule();
2152
- const doc = globalThis.document;
2153
- doc?.addEventListener?.('visibilitychange', onVisibility);
2154
- return () => {
2155
- disposed = true;
2156
- if (timer !== null) clearTimeout(timer);
2157
- timer = null;
2158
- doc?.removeEventListener?.('visibilitychange', onVisibility);
2159
- };
2160
- }, [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]);
2161
2261
  return { ...plan, refreshError };
2162
2262
  }
2163
2263
 
@@ -2242,6 +2342,12 @@ function TaskListNote({ task, onOpen }) {
2242
2342
  // EXISTING store actions and the EXISTING `TaskDetail` panel. Every click carries a
2243
2343
  // stable `taskId`, so a later background refresh (which replaces the whole tree)
2244
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.
2245
2351
 
2246
2352
  /** How many rounds of one chain are listed without expanding that chain further. */
2247
2353
  const CHAIN_ROUNDS_VISIBLE = 3;
@@ -2295,17 +2401,56 @@ function chainsOfTreeNode(node) {
2295
2401
  return node.chain ? [node.chain] : [];
2296
2402
  }
2297
2403
 
2298
- function ChainRounds({ chain, store, snapshot, onOpen, expanded, onToggle }) {
2299
- const rounds = chain.rounds ?? [];
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]);
2300
2426
  return (
2301
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}
2302
2445
  <ul className="dshdg-tree-rounds">
2303
- {rounds.map((task, index) => expanded || index >= rounds.length - CHAIN_ROUNDS_VISIBLE || task.taskId === snapshot.taskDetail?.taskId ? (
2304
- <ChainRoundRow key={task.taskId} store={store} round={{ task, round: index + 1,
2305
- position: index === 0 ? 'first' : 'rectification' }} snapshot={snapshot} onOpen={onOpen} />
2306
- ) : null)}
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))}
2307
2452
  </ul>
2308
- {rounds.length > CHAIN_ROUNDS_VISIBLE ? <button type="button" data-dshdg-chain-more={chain.chainId}
2453
+ {!forceExpanded && !newestFirst && rounds.length > CHAIN_ROUNDS_VISIBLE ? <button type="button" data-dshdg-chain-more={chain.chainId}
2309
2454
  onClick={onToggle} aria-expanded={expanded}>
2310
2455
  {expanded ? '只看最近三轮' : '显示全部 ' + rounds.length + ' 轮'}
2311
2456
  </button> : null}
@@ -2400,7 +2545,7 @@ function ChainRoundRow({ store, round, snapshot, onOpen }) {
2400
2545
  * `expandedRounds`, `setExpandedRounds`, `onOpen`.
2401
2546
  * @returns {object} the node.
2402
2547
  */
2403
- function TaskTreeItem({ node, store, snapshot, collapsed, setCollapsed, expandedRounds, setExpandedRounds, onOpen, onArchive, forceOpen }) {
2548
+ function TaskTreeItem({ node, store, snapshot, collapsed, setCollapsed, expandedRounds, setExpandedRounds, onOpen, onArchive, forceOpen, cleanup }) {
2404
2549
  const children = Array.isArray(node.children) ? node.children : [];
2405
2550
  const key = node.nodeId;
2406
2551
  const open = forceOpen || !collapsed.has(key);
@@ -2458,7 +2603,8 @@ function TaskTreeItem({ node, store, snapshot, collapsed, setCollapsed, expanded
2458
2603
  {goal === null ? null : <p className="dshdg-hint">{`目标:${boundedText(goal, 400)}`}</p>}
2459
2604
  {completion === null ? null : <p className="dshdg-hint">{`已完成:${boundedText(completion, 400)}`}</p>}
2460
2605
  {chains.map((chain) => <ChainRounds key={chain.chainId} chain={chain} store={store} snapshot={snapshot}
2461
- onOpen={onOpen} expanded={expandedRounds.has(chain.chainId)} onToggle={() => setExpandedRounds((old) => {
2606
+ onOpen={onOpen} expanded={expandedRounds.has(chain.chainId)} forceExpanded={forceOpen}
2607
+ cleanup={cleanup} onToggle={() => setExpandedRounds((old) => {
2462
2608
  const next = new Set(old);
2463
2609
  if (next.has(chain.chainId)) next.delete(chain.chainId);
2464
2610
  else next.add(chain.chainId);
@@ -2479,6 +2625,7 @@ function TaskTreeItem({ node, store, snapshot, collapsed, setCollapsed, expanded
2479
2625
  onOpen={onOpen}
2480
2626
  onArchive={onArchive}
2481
2627
  forceOpen={forceOpen}
2628
+ cleanup={cleanup}
2482
2629
  />
2483
2630
  ))}
2484
2631
  </ul>
@@ -2491,12 +2638,21 @@ function TaskTreeItem({ node, store, snapshot, collapsed, setCollapsed, expanded
2491
2638
 
2492
2639
  function TaskTreePanel({ store, snapshot, onOpen }) {
2493
2640
  const view = snapshot.tree ?? null;
2641
+ const [recordView, setRecordView] = useState('recent');
2494
2642
  const [collapsed, setCollapsed] = useState(() => new Set());
2495
2643
  const [expandedRounds, setExpandedRounds] = useState(() => new Set());
2496
2644
  const [projectKey, setProjectKey] = useState('');
2497
2645
  const [filter, setFilter] = useState('all');
2498
2646
  const [search, setSearch] = useState('');
2647
+ const [fromDay, setFromDay] = useState('');
2648
+ const [toDay, setToDay] = useState('');
2499
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);
2500
2656
  if (view === null) {
2501
2657
  return <p className="dshdg-faint" data-dshdg-tree-unavailable="">
2502
2658
  {snapshot.tasksError ? '任务树读取失败,下面显示已有记录。' : '当前宿主按列表显示任务。'}
@@ -2504,43 +2660,213 @@ function TaskTreePanel({ store, snapshot, onOpen }) {
2504
2660
  }
2505
2661
  const counts = view.counts ?? {};
2506
2662
  const canArchive = view.displayArchiveAvailable === true;
2507
- const { groups, archiveCount } = projectTaskView(view, {
2663
+ const dateRange = { from: fromDay, to: toDay };
2664
+ const { groups, recent, archiveCount, dateError, dateRangeText } = projectTaskView(view, {
2508
2665
  projectKey, filter: canArchive ? filter : (filter === 'archive' ? 'all' : filter), search,
2509
2666
  selectedTaskId: snapshot.taskDetail?.taskId ?? null,
2667
+ dateRange,
2510
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
+ };
2511
2697
  async function archive(node, archived) {
2512
2698
  setArchiveError(null);
2513
2699
  const result = await store.setDisplayArchive(node.nodeId, archived);
2514
2700
  if (!result.ok) setArchiveError(describeError(result.error));
2515
2701
  else if (archived && snapshot.taskDetail) store.closeTask();
2516
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
+ }
2517
2757
  return (
2518
2758
  <section className="dshdg-card" aria-labelledby="dshdg-tree-title" data-dshdg-task-tree="">
2519
2759
  <div className="dshdg-row">
2520
- <h3 id="dshdg-tree-title">任务树</h3>
2760
+ <h3 id="dshdg-tree-title">任务记录</h3>
2521
2761
  <span className="dshdg-spacer" />
2522
- <span className="dshdg-hint" data-dshdg-tree-counts="">
2523
- {`规划节点 ${counts.planNodes ?? 0} · 执行链 ${counts.taskChains ?? 0} · 顶层 ${counts.roots ?? view.roots.length}`}
2524
- </span>
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}
2525
2788
  </div>
2526
2789
  <div className="dshdg-tree-filters">
2527
- <label>项目<select value={projectKey} onChange={(event) => { setProjectKey(event.target.value); store.closeTask(); }}>
2790
+ <label>项目<select value={projectKey} onChange={updateFilter(setProjectKey)}>
2528
2791
  <option value="">所有项目</option>
2529
2792
  {view.projects.map((p) => <option key={p.projectKey} value={p.projectKey}>{p.shortPath ? `${p.name} · ${p.shortPath}` : p.name}</option>)}
2530
2793
  </select></label>
2531
- <label>状态<select value={filter} onChange={(event) => { setFilter(event.target.value); store.closeTask(); }}>
2794
+ <label>状态<select value={filter} onChange={updateFilter(setFilter)}>
2532
2795
  <option value="all">全部</option>
2533
2796
  <option value="attention">需要处理</option>
2534
2797
  <option value="active">执行中</option>
2535
2798
  <option value="done">已完成</option>
2536
2799
  {canArchive ? <option value="archive">{`已归档(${archiveCount})`}</option> : null}
2537
2800
  </select></label>
2538
- <label>搜索<input type="search" value={search} onChange={(event) => { setSearch(event.target.value); store.closeTask(); }} placeholder="项目、标题或任务编号" /></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>
2539
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>}
2540
2817
  {filter === 'archive' ? <p className="dshdg-hint">归档只影响任务的显示。会话和历史仍按原规则保留。</p> : null}
2541
2818
  {view.displayArchiveError ? <p className="dshdg-warn" role="alert">归档记录暂不可读,已显示全部任务。</p> : null}
2542
2819
  {archiveError ? <p className="dshdg-warn" role="alert">{`更新归档失败。${archiveError}`}</p> : null}
2543
- {groups.length === 0 ? (
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 ? (
2544
2870
  <p className="dshdg-faint" data-dshdg-tree-empty="">{view.roots.length === 0 ? '还没有规划节点或执行记录。' : '没有符合当前条件的任务。'}</p>
2545
2871
  ) : groups.map((group) => (
2546
2872
  <section className="dshdg-tree-project" key={group.projectKey} data-dshdg-project={group.projectKey}>
@@ -2549,7 +2875,9 @@ function TaskTreePanel({ store, snapshot, onOpen }) {
2549
2875
  <ul className="dshdg-tree-roots">
2550
2876
  {group.roots.map((node) => <TaskTreeItem key={node.nodeId} node={node} store={store} snapshot={snapshot}
2551
2877
  collapsed={collapsed} setCollapsed={setCollapsed} expandedRounds={expandedRounds} setExpandedRounds={setExpandedRounds}
2552
- onOpen={onOpen} onArchive={canArchive ? archive : null} forceOpen={search.trim() !== '' || filter !== 'all'} />)}
2878
+ onOpen={onOpen} onArchive={canArchive ? archive : null}
2879
+ forceOpen={search.trim() !== '' || filter !== 'all' || rangeActive || cleanupActive}
2880
+ cleanup={cleanup} />)}
2553
2881
  </ul>
2554
2882
  </section>
2555
2883
  ))}
@@ -2886,9 +3214,9 @@ function TasksPanel({ store, snapshot }) {
2886
3214
  <div className="dshdg-row">
2887
3215
  <p className="dshdg-muted">这里只记录执行事实。执行完成不等于被接受:“等待宿主审查”要由宿主(例如 Codex)单独给出结论。</p>
2888
3216
  <span className="dshdg-spacer" />
2889
- <span className="dshdg-hint">
3217
+ <span className="dshdg-hint" data-dshdg-refresh-hint="">
2890
3218
  {changing !== true
2891
- ? '当前没有会变化的记录,不会自动刷新。'
3219
+ ? '当前没有会变化的记录。页面打开且可见时,每 15 秒只读检查一次,新派发的任务会自动出现;切回本页会立即刷新。'
2892
3220
  : `${liveCount > 0 ? `有 ${liveCount} 个进行中的任务;` : ''}有记录可能变化(待审或结论保存中),页面可见时每 5 秒只读刷新一次(不调用模型)。`}
2893
3221
  </span>
2894
3222
  <button type="button" disabled={snapshot.loading?.tasks === true} onClick={() => { void store.refreshTasks('manual'); }}>
@@ -3125,7 +3453,6 @@ function CodexPanel({ store, snapshot }) {
3125
3453
  const TABS = Object.freeze([
3126
3454
  { key: 'providers', label: '接口管理' },
3127
3455
  { key: 'execution', label: '执行设置' },
3128
- { key: 'review', label: '附加审查' },
3129
3456
  { key: 'tasks', label: '任务记录' },
3130
3457
  { key: 'codex', label: 'Codex 集成' },
3131
3458
  ]);
@@ -3208,8 +3535,11 @@ export function DelegateConfigPage(props) {
3208
3535
  >
3209
3536
  {tab === 'providers' ? <ProvidersPanel store={store} snapshot={snapshot} /> : null}
3210
3537
  {tab === 'execution' ? <ExecutionPanel store={store} snapshot={snapshot} /> : null}
3211
- {tab === 'review' ? <ReviewPanel store={store} snapshot={snapshot} /> : null}
3212
- {tab === 'tasks' ? <TasksPanel store={store} snapshot={snapshot} /> : null}
3538
+ {tab === 'tasks' ? (
3539
+ <SessionNavigation.Provider value={props.uiWorkspace || props.workspaces ? props : null}>
3540
+ <TasksPanel store={store} snapshot={snapshot} />
3541
+ </SessionNavigation.Provider>
3542
+ ) : null}
3213
3543
  {tab === 'codex' ? <CodexPanel store={store} snapshot={snapshot} /> : null}
3214
3544
  </div>
3215
3545
 
@@ -3237,10 +3567,31 @@ export function DelegateConfigPage(props) {
3237
3567
  /** Re-exported so the documented contract and tests share one name for the body document. */
3238
3568
  export { documentFromDraft, describeError, exportDocument, planCreateRequest };
3239
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
+
3240
3586
 
3241
3587
  /**
3242
- * Re-exported so a consumer (and `lib/client.d.ts`) reaches the native navigation
3243
- * through the one module the bundle exports, rather than a second module identity.
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.
3244
3595
  */
3245
3596
  export {
3246
3597
  MAIN_SLOT,
@@ -3264,3 +3615,44 @@ export {
3264
3615
  TaskbridgeNavPanel,
3265
3616
  TaskbridgeSidebarIcon,
3266
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';