dsh-workplan 1.5.2 → 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/client.js CHANGED
@@ -19,21 +19,26 @@ window.__ModuleLoader__.load({
19
19
  "panel": "任务进度",
20
20
  "groupLive": "进行中",
21
21
  "groupDone": "已完成",
22
+ "groupEnded": "已结束",
22
23
  "groupLiveHint": "还没结束,正在或即将推进",
23
24
  "groupDoneHint": "已全部完成并收尾",
25
+ "groupEndedHint": "这一轮已经停了,没有东西在跑;说「续跑」可继续推进",
24
26
  "groupCollapse": "收起",
25
27
  "groupExpand": "展开",
26
28
  "groupNeeds": "需处理",
27
29
  "groupLiveEmpty": "没有进行中的任务",
28
30
  "groupDoneEmpty": "还没有完成的任务",
31
+ "groupEndedEmpty": "没有已结束但未完成的任务",
29
32
  "groupSummary": "未完成 {open} / 已完成 {done}(完成率 {pct}%)",
30
33
  "groupSummaryNoRate": "未完成 {open} / 已完成 {done}(完成率暂无数据)",
31
34
  "groupAria": "{title}组,{plans} 个计划,共 {total} 件具体工作,已完成 {done} 件,完成率 {pct}%。其中正在做 {active} 件、卡住 {blocked} 件、还没开始 {pending} 件。",
32
35
  "groupAriaEmpty": "{title}组,{plans} 个计划,暂无具体工作项。",
33
36
  "groupPlansLabel": "个计划",
34
- "chartGroups": "两类计划数量占比",
35
- "chartLive": "进行中计划完成度(按工作项)",
36
- "chartMore": "另有 {n} 个进行中计划未画入图表",
37
+ "chartGroups": "计划数量与完成情况",
38
+ "chartOpen": "未结束",
39
+ "chartDone": "已完成",
40
+ "chartLive": "未完成计划的完成度(按工作项)",
41
+ "chartMore": "另有 {n} 个未完成计划未画入图表",
37
42
  "title": "任务进度:一眼看懂",
38
43
  "subtitle": "用大白话说明:现在要做什么、谁在做、做到哪一步、接下来做什么。",
39
44
  "helpTitle": "先看这三句",
@@ -67,7 +72,8 @@ window.__ModuleLoader__.load({
67
72
  "blocked": "卡住了",
68
73
  "paused": "预算用完,可续跑",
69
74
  "degraded": "安排失败",
70
- "cancelled": "已取消"
75
+ "cancelled": "已取消",
76
+ "ended": "已结束,可续跑"
71
77
  },
72
78
  "status": {
73
79
  "pending": "还没开始",
@@ -172,6 +178,7 @@ window.__ModuleLoader__.load({
172
178
  "overview": "进度总览",
173
179
  "statusChart": "状态分布",
174
180
  "taskChart": "每个任务的进度",
181
+ "backToTop": "回到顶部",
175
182
  "jumpToTask": "跳转到任务明细",
176
183
  "scopeAll": "当前各会话最新计划汇总",
177
184
  "scopeThis": "本计划",
@@ -183,6 +190,7 @@ window.__ModuleLoader__.load({
183
190
  "en": {
184
191
  "groupLive": "In progress",
185
192
  "groupDone": "Completed",
193
+ "groupEnded": "Ended",
186
194
  "groupLiveHint": "Not finished yet — running or about to run",
187
195
  "groupDoneHint": "All work finished and wrapped up",
188
196
  "groupCollapse": "Collapse",
@@ -190,14 +198,17 @@ window.__ModuleLoader__.load({
190
198
  "groupNeeds": "needs attention",
191
199
  "groupLiveEmpty": "No work in progress",
192
200
  "groupDoneEmpty": "Nothing completed yet",
201
+ "groupEndedEmpty": "No ended-but-unfinished plans",
193
202
  "groupSummary": "Open {open} / done {done} ({pct}% complete)",
194
203
  "groupSummaryNoRate": "Open {open} / done {done} (completion rate unavailable)",
195
204
  "groupAria": "{title} group: {plans} plan(s), {total} work item(s), {done} done, {pct}% complete. Right now {active} in progress, {blocked} blocked, {pending} not started.",
196
205
  "groupAriaEmpty": "{title} group: {plans} plan(s), no work items yet.",
197
206
  "groupPlansLabel": "plan(s)",
198
- "chartGroups": "Plan count by group",
199
- "chartLive": "In-progress plans by work item",
200
- "chartMore": "{n} more in-progress plans not drawn",
207
+ "chartGroups": "Plan count and completion",
208
+ "chartOpen": "Open",
209
+ "chartDone": "Completed",
210
+ "chartLive": "Open plans by work item",
211
+ "chartMore": "{n} more open plans not drawn",
201
212
  "panel": "Task progress",
202
213
  "title": "Task progress at a glance",
203
214
  "subtitle": "Plain language: what this is, who is doing it, how far along it is, and what happens next.",
@@ -232,7 +243,8 @@ window.__ModuleLoader__.load({
232
243
  "blocked": "Stuck",
233
244
  "paused": "Paused (budget spent)",
234
245
  "degraded": "Planning failed",
235
- "cancelled": "Cancelled"
246
+ "cancelled": "Cancelled",
247
+ "ended": "Ended (resumable)"
236
248
  },
237
249
  "status": {
238
250
  "pending": "Not started",
@@ -337,6 +349,7 @@ window.__ModuleLoader__.load({
337
349
  "overview": "Progress overview",
338
350
  "statusChart": "Status mix",
339
351
  "taskChart": "Progress by task",
352
+ "backToTop": "Back to top",
340
353
  "jumpToTask": "Jump to task details",
341
354
  "scopeAll": "Latest plan per live session",
342
355
  "scopeThis": "This plan",
@@ -402,6 +415,7 @@ window.__ModuleLoader__.load({
402
415
  .dsh-wp-group::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 4px; }
403
416
  .dsh-wp-group--live::before { background: linear-gradient(180deg, #fb923c, #f97316); }
404
417
  .dsh-wp-group--done::before { background: linear-gradient(180deg, #38bdf8, #0284c7); }
418
+ .dsh-wp-group--ended::before { background: linear-gradient(180deg, #94a3b8, #64748b); }
405
419
  /* T6 — 组头多出一行完成度摘要,底部内边距 10px → 6px,两组仍在同一屏内读完。 */
406
420
  .dsh-wp-group-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 0 4px 6px; }
407
421
  .dsh-wp-group-head--btn { width: 100%; background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; border-radius: 8px; }
@@ -428,6 +442,8 @@ window.__ModuleLoader__.load({
428
442
  .dsh-wp-group-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
429
443
  .dsh-wp-group--live .dsh-wp-group-dot { background: #f97316; box-shadow: 0 0 0 4px rgba(249,115,22,.16); animation: dsh-wp-pulse 1.8s ease-in-out infinite; }
430
444
  .dsh-wp-group--done .dsh-wp-group-dot { background: #0ea5e9; box-shadow: 0 0 0 4px rgba(14,165,233,.14); }
445
+ /* [1.6.0] 已结束:灰点、不脉冲——"没有东西在跑"这件事不允许用动画表达。 */
446
+ .dsh-wp-group--ended .dsh-wp-group-dot { background: #94a3b8; box-shadow: 0 0 0 4px rgba(148,163,184,.16); }
431
447
  .dsh-wp-group-title { font-size: 15px; font-weight: 700; letter-spacing: .2px; color: var(--dsw-alias-label-primary, #0f172a); }
432
448
  /* 设计稿 §6.1:橙 #f97316 / 白 ≈2.8:1、蓝 #0ea5e9 / 白 ≈2.77:1,均不足 4.5:1,
433
449
  15px 粗体也不算法定「大字号」,所以组头一律用主文本色;品牌色只做「面」——
@@ -436,6 +452,7 @@ window.__ModuleLoader__.load({
436
452
  .dsh-wp-group-count { min-width: 22px; padding: 0 7px; height: 20px; border-radius: 999px; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; color: var(--dsw-alias-label-primary, #0f172a); font-variant-numeric: tabular-nums; }
437
453
  .dsh-wp-group--live .dsh-wp-group-count { background: rgba(249,115,22,.14); box-shadow: inset 0 0 0 1px rgba(249,115,22,.34); }
438
454
  .dsh-wp-group--done .dsh-wp-group-count { background: rgba(14,165,233,.14); box-shadow: inset 0 0 0 1px rgba(14,165,233,.34); }
455
+ .dsh-wp-group--ended .dsh-wp-group-count { background: rgba(148,163,184,.16); box-shadow: inset 0 0 0 1px rgba(148,163,184,.36); }
439
456
  /* WCAG AA:错误色叠 12% 红底后,浅色 #ec1313 只有 3.70:1;与主文本色混合 20%
440
457
  让浅色变深、深色变浅,两套主题都 ≥4.5:1(实测 5.16:1 / 5.67:1)。 */
441
458
  .dsh-wp-group-alert { font-size: 12px; font-weight: 650; color: var(--dsw-alias-state-error-primary, #ef4444); color: color-mix(in srgb, var(--dsw-alias-state-error-primary, #ef4444) 80%, var(--dsw-alias-label-primary, #0f172a) 20%); background: rgba(239,68,68,.12); padding: 1px 8px; border-radius: 999px; }
@@ -518,6 +535,35 @@ window.__ModuleLoader__.load({
518
535
  }
519
536
  .dsh-wp-button:hover { background: var(--dsw-alias-bg-layer-2); }
520
537
  .dsh-wp-button:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: 2px; }
538
+ /* [T4] 回到顶部:sticky 的包含块与粘附视口就是 .dsh-wp 的 padding box,
539
+ 钉住的是面板可视区右下角。禁止 fixed(钉到浏览器视口)与 absolute
540
+ (随内容滚走)。始终挂载、用 visibility 藏显,避免显隐改变 scrollHeight。 */
541
+ .dsh-wp-backtop {
542
+ position: sticky;
543
+ bottom: 16px;
544
+ z-index: 30;
545
+ display: flex;
546
+ align-items: center;
547
+ justify-content: center;
548
+ width: 44px;
549
+ height: 44px;
550
+ margin: 12px 0 0 auto;
551
+ padding: 0;
552
+ border-radius: 50%;
553
+ border: 1px solid var(--dsw-alias-border-l1);
554
+ background: var(--dsw-alias-bg-layer-1);
555
+ color: var(--dsw-alias-label-primary);
556
+ font: inherit;
557
+ font-size: 18px;
558
+ line-height: 1;
559
+ cursor: pointer;
560
+ touch-action: manipulation;
561
+ visibility: hidden;
562
+ box-shadow: 0 2px 8px rgba(15,23,42,.18);
563
+ }
564
+ .dsh-wp-backtop[data-visible="true"], .dsh-wp-backtop:focus-within { visibility: visible; }
565
+ .dsh-wp-backtop:hover { background: var(--dsw-alias-bg-layer-2); }
566
+ .dsh-wp-backtop:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: 2px; }
521
567
  .dsh-wp-banner {
522
568
  border: 1px solid var(--dsw-alias-border-l1);
523
569
  background: var(--dsw-alias-bg-layer-1);
@@ -748,6 +794,7 @@ window.__ModuleLoader__.load({
748
794
  .dsh-wp-group::before { content: ''; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; opacity: .9; }
749
795
  .dsh-wp-group--live::before { background: linear-gradient(180deg, #fbbf24, #ea580c); }
750
796
  .dsh-wp-group--done::before { background: linear-gradient(180deg, #7dd3fc, #0369a1); }
797
+ .dsh-wp-group--ended::before { background: linear-gradient(180deg, #cbd5e1, #94a3b8); }
751
798
  .dsh-wp-group--done { opacity: .97; }
752
799
  .dsh-wp-group-head--btn { transition: background-color .16s ease; }
753
800
  .dsh-wp-group-head--btn:hover { background: rgba(148,163,184,.10); }
@@ -980,6 +1027,12 @@ window.__ModuleLoader__.load({
980
1027
  function phaseTone(phase) {
981
1028
  if (phase === 'blocked')
982
1029
  return 'blocked';
1030
+ /*
1031
+ * [1.6.0] `ended` = 这一轮停了,但计划没做完。它既不是成功(done),也不能
1032
+ * 冒充正在干活(active);用中性 idle 色,卡在哪由二级徽标 suspendedPhase 说明。
1033
+ */
1034
+ if (phase === 'ended')
1035
+ return 'idle';
983
1036
  if (phase === 'degraded' || phase === 'cancelled' || phase === 'paused')
984
1037
  return 'warn';
985
1038
  if (phase === 'integrating' || phase === 'done')
@@ -988,6 +1041,23 @@ window.__ModuleLoader__.load({
988
1041
  return 'active';
989
1042
  return 'idle';
990
1043
  }
1044
+ /*
1045
+ * [1.6.0] 「已结束」徽标要把「停在哪儿」一起说出来。
1046
+ *
1047
+ * 只说「已结束,可续跑」,用户不知道是预算用完、卡住了、还是压根没开始;
1048
+ * 只说原阶段(「正在做」),又会像事故截图那样暗示还在跑。两段式表达:
1049
+ * 终态 + 原阶段,一次说清两个事实。
1050
+ */
1051
+ function phaseLabel(phase, session, t) {
1052
+ const base = t(`phase.${phase}`);
1053
+ if (phase !== 'ended')
1054
+ return base;
1055
+ const suspended = String(session?.suspendedPhase ?? '');
1056
+ if (!suspended)
1057
+ return base;
1058
+ const detail = t(`phase.${suspended}`);
1059
+ return detail && detail !== base ? `${base} · ${detail}` : base;
1060
+ }
991
1061
  function allEntries(session) {
992
1062
  const byId = new Map((Array.isArray(session?.statuses) ? session.statuses : []).map((item) => [item.subtaskId, item]));
993
1063
  const entries = [];
@@ -1637,7 +1707,7 @@ window.__ModuleLoader__.load({
1637
1707
  panelClassName: 'dsh-wp-session-body',
1638
1708
  title: session.title || t('panel'),
1639
1709
  meta: h(PlanViz, { t, counts, now, rows: stageRows }),
1640
- badge: h(Pill, { tone }, t(`phase.${phase}`)),
1710
+ badge: h(Pill, { tone }, phaseLabel(phase, session, t)),
1641
1711
  }, session.updatedAt
1642
1712
  ? h('div', { className: 'dsh-wp-meta dsh-wp-session-updated' }, `${t('updatedAt')} ${formatTime(session.updatedAt)}`)
1643
1713
  : null, open === true ? h(PlanOverview, { t, stats, counts, rows: stageRows }) : null, session.degraded ? h('div', { className: 'dsh-wp-banner dsh-wp-banner--degraded' }, h('strong', null, t('degraded')), h('div', null, plainError(session.error || '')), h('div', { className: 'dsh-wp-muted' }, t('degradedHint'))) : null, h(Guide, { session, t }), departments.length ? h('div', { className: 'dsh-wp-section' }, h('div', { className: 'dsh-wp-section-title' }, t('who')), h('div', { className: 'dsh-wp-departments' }, departments.map((dept) => h(Pill, { key: dept.id, tone: dept.blocked > 0 ? 'blocked' : dept.done === dept.total ? 'done' : 'active' }, `${deptName(t, dept.id)} ${dept.done}/${dept.total} ${t('stats.done')}`)))) : null, h('div', { className: 'dsh-wp-section' }, h('div', { className: 'dsh-wp-section-title' }, t('steps')), (session.stages || []).map((stage, index) => h(StageCard, {
@@ -1722,7 +1792,7 @@ window.__ModuleLoader__.load({
1722
1792
  charts.push(new lib(canvasA, {
1723
1793
  type: 'doughnut',
1724
1794
  data: {
1725
- labels: [t('groupLive'), t('groupDone')],
1795
+ labels: [t('chartOpen'), t('chartDone')],
1726
1796
  datasets: [{ data: [liveCount, doneCount], backgroundColor: [liveFill, doneFill], borderWidth: 0, hoverOffset: 5 }],
1727
1797
  },
1728
1798
  options: {
@@ -1783,8 +1853,8 @@ window.__ModuleLoader__.load({
1783
1853
  // 「无 canvas → 不建图 → 不 ready → 无 canvas」的死循环(T3 实测
1784
1854
  // 探针输出 canvasNodes:0 / fallbackBars:1)。改为并存:
1785
1855
  // fallback 在 ready 前可见,ready 后由 CSS 隐藏,canvas 反向隐藏。
1786
- h('div', { className: 'dsh-wp-chart-canvas' }, h('canvas', { 'data-chart': 'groups', role: 'img', 'aria-label': `${t('groupLive')} ${liveCount} / ${t('groupDone')} ${doneCount}` })), chartState !== 'ready'
1787
- ? h('div', { className: 'dsh-wp-fallback' }, h('div', { className: 'dsh-wp-fallback-bar', role: 'img', 'aria-label': `${t('groupLive')} ${liveCount} / ${t('groupDone')} ${doneCount}` }, h('span', { className: 'dsh-wp-fallback-live', style: { width: `${livePct}%` } }), h('span', { className: 'dsh-wp-fallback-done', style: { width: `${donePct}%` } })), h('div', { className: 'dsh-wp-fallback-legend' }, h('span', null, h('i', { className: 'dsh-wp-fallback-key dsh-wp-fallback-key--live' }), `${t('groupLive')} ${liveCount}`), h('span', null, h('i', { className: 'dsh-wp-fallback-key dsh-wp-fallback-key--done' }), `${t('groupDone')} ${doneCount}`)))
1856
+ h('div', { className: 'dsh-wp-chart-canvas' }, h('canvas', { 'data-chart': 'groups', role: 'img', 'aria-label': `${t('chartOpen')} ${liveCount} / ${t('chartDone')} ${doneCount}` })), chartState !== 'ready'
1857
+ ? h('div', { className: 'dsh-wp-fallback' }, h('div', { className: 'dsh-wp-fallback-bar', role: 'img', 'aria-label': `${t('chartOpen')} ${liveCount} / ${t('chartDone')} ${doneCount}` }, h('span', { className: 'dsh-wp-fallback-live', style: { width: `${livePct}%` } }), h('span', { className: 'dsh-wp-fallback-done', style: { width: `${donePct}%` } })), h('div', { className: 'dsh-wp-fallback-legend' }, h('span', null, h('i', { className: 'dsh-wp-fallback-key dsh-wp-fallback-key--live' }), `${t('chartOpen')} ${liveCount}`), h('span', null, h('i', { className: 'dsh-wp-fallback-key dsh-wp-fallback-key--done' }), `${t('chartDone')} ${doneCount}`)))
1788
1858
  : null), (liveBars || []).length
1789
1859
  ? h('div', { className: 'dsh-wp-chart-card' }, h('div', { className: 'dsh-wp-chart-title' }, t('chartLive')), h('div', { className: 'dsh-wp-chart-canvas' }, h('canvas', { 'data-chart': 'live', role: 'img', 'aria-label': t('chartLive') })), hiddenBars > 0 ? h('div', { className: 'dsh-wp-chart-more' }, fill(t('chartMore'), { n: hiddenBars })) : null)
1790
1860
  : null);
@@ -1883,11 +1953,18 @@ window.__ModuleLoader__.load({
1883
1953
  : null), h('span', { className: 'dsh-wp-group-ring-label' }, value === null ? '—' : `${value}%`));
1884
1954
  }
1885
1955
  function SessionGroup({ group, list, hasLive, urgent, t, openSessionId, setOpenSessionId }) {
1956
+ /*
1957
+ * [1.6.0] 三个分组共用一套组件:live(真的在跑)、ended(这一轮停了但没做完)、
1958
+ * done(全部完成)。`ended` 是本次事故的修复核心——它必须是一个**独立分组**,
1959
+ * 而不是被塞回「进行中」:会话已经结束的事实不允许用「进行中」这三个字表达。
1960
+ */
1886
1961
  const isDone = group === 'done';
1962
+ const isEnded = group === 'ended';
1963
+ const keySuffix = isDone ? 'Done' : isEnded ? 'Ended' : 'Live';
1887
1964
  // 设计稿 §6.4 #1/#6:已完成组在有进行中任务时默认折叠,避免历史任务抢走
1888
1965
  // 「进行中」的视觉权重;没有进行中任务时默认展开,空的进度栏仍是空的。
1889
- // 折叠态由本组件自己持有(不给 users 存偏好),刷新后回到默认,符合 §7.3「不打扰」。
1890
- const [open, setOpen] = useState(!(isDone && hasLive));
1966
+ // [1.6.0] 「已结束」组同理:还有东西在跑时收起来,只留组头一行结论。
1967
+ const [open, setOpen] = useState(!((isDone || isEnded) && hasLive));
1891
1968
  // §7.3「不打扰」的自动展开:只在这两种情形打开一次,不做反复弹开——
1892
1969
  // ① 进行中清零(最后一个任务完成);② 用户正展开着的卡片被移进本组。
1893
1970
  // 依赖都是布尔值,轮询刷新不会重复触发。
@@ -1896,7 +1973,7 @@ window.__ModuleLoader__.load({
1896
1973
  setOpen(true); }, [hasLive]);
1897
1974
  useEffect(() => { if (holdsOpenCard)
1898
1975
  setOpen(true); }, [holdsOpenCard]);
1899
- const collapsible = isDone && list.length > 0;
1976
+ const collapsible = (isDone || isEnded) && list.length > 0;
1900
1977
  // 折叠只隐藏、不卸载:`hidden` 必须是布尔 true,不能传空字符串——
1901
1978
  // React 对 `hidden` 走 DOM 布尔属性赋值,`el.hidden = ''` 会得到 false,
1902
1979
  // 只剩 CSS 类在遮挡;那样「折叠态 DOM 保留 + 无障碍语义」就不成立。
@@ -1907,8 +1984,8 @@ window.__ModuleLoader__.load({
1907
1984
  // T6:组头完成度摘要 + 零依赖进度环。数值只来自 groupTotals(list),
1908
1985
  // 先用纯文本给出「进行中 N / 已完成 M(完成率 x%)」,不点开、不看颜色也能读出进度。
1909
1986
  const totals = useMemo(() => groupTotals(list), [list]);
1910
- const groupTitle = t(isDone ? 'groupDone' : 'groupLive');
1911
- const hintText = t(isDone ? 'groupDoneHint' : 'groupLiveHint');
1987
+ const groupTitle = t(`group${keySuffix}`);
1988
+ const hintText = t(`group${keySuffix}Hint`);
1912
1989
  // 用户 Q3:0/0 时不再显示「未完成 0 / 已完成 0(完成率暂无数据)」——
1913
1990
  // 环上已经是「—」,组内空态也已说明没有工作项;再重复一遍 0/0 只是噪声。
1914
1991
  // 全部做完(100%)仍保留整句,因为那时「未完成 0」正是用户要找的结论。
@@ -1973,7 +2050,7 @@ window.__ModuleLoader__.load({
1973
2050
  open: openSessionId === session.sessionId,
1974
2051
  onToggle: (next) => setOpenSessionId(next ? session.sessionId : null),
1975
2052
  })))
1976
- : h('div', { className: 'dsh-wp-group-empty' }, t(isDone ? 'groupDoneEmpty' : 'groupLiveEmpty')));
2053
+ : h('div', { className: 'dsh-wp-group-empty' }, t(`group${keySuffix}Empty`)));
1977
2054
  }
1978
2055
  function Donut({ totals, t }) {
1979
2056
  const total = Math.max(0, Number(totals?.total) || 0);
@@ -2036,9 +2113,11 @@ window.__ModuleLoader__.load({
2036
2113
  'aria-label': `${t('jumpToTask')} ${session.title || t('panel')}`,
2037
2114
  onClick: () => { if (typeof onSelect === 'function')
2038
2115
  onSelect(session.sessionId); },
2039
- }, h('div', { className: 'dsh-wp-bar-head' }, h('span', { className: 'dsh-wp-bar-title' }, session.title || t('panel')), h('span', { className: 'dsh-wp-bar-value' }, `${counts.done}/${counts.total}`)), h('div', { className: 'dsh-wp-bar-track' }, h('div', { className: `dsh-wp-bar-fill dsh-wp-bar-fill--${tone}`, style: { width: `${percent}%` } })), h('div', { className: 'dsh-wp-bar-meta' }, h('span', null, t(`phase.${phase}`)), h('span', null, `${percent}%`)));
2116
+ }, h('div', { className: 'dsh-wp-bar-head' }, h('span', { className: 'dsh-wp-bar-title' }, session.title || t('panel')), h('span', { className: 'dsh-wp-bar-value' }, `${counts.done}/${counts.total}`)), h('div', { className: 'dsh-wp-bar-track' }, h('div', { className: `dsh-wp-bar-fill dsh-wp-bar-fill--${tone}`, style: { width: `${percent}%` } })), h('div', { className: 'dsh-wp-bar-meta' }, h('span', null, phaseLabel(phase, session, t)), h('span', null, `${percent}%`)));
2040
2117
  }));
2041
2118
  }
2119
+ /* [T4] 回到顶部的显示阈值(px):scrollTop 严格大于该值才显示。 */
2120
+ const BACK_TOP_THRESHOLD = 200;
2042
2121
  function Dashboard({ t }) {
2043
2122
  const { sessions, error, loading, updatedAt, reload } = usePlans();
2044
2123
  const [openSessionId, setOpenSessionId] = useState(null);
@@ -2084,6 +2163,7 @@ window.__ModuleLoader__.load({
2084
2163
  }, [activeSessions]);
2085
2164
  const groups = useMemo(() => {
2086
2165
  const live = [];
2166
+ const ended = [];
2087
2167
  const finished = [];
2088
2168
  const urgentPhases = ['blocked', 'degraded', 'paused'];
2089
2169
  /*
@@ -2093,10 +2173,17 @@ window.__ModuleLoader__.load({
2093
2173
  * 14/14、100% 的计划带着 integrating 被塞进 live 组,组头于是出现
2094
2174
  * 「未完成 0 / 已完成 14(完成率 100%)」却仍标着「进行中」。
2095
2175
  * `planPhaseOf` 让分组、组头计数、卡片胶囊共用同一个结论。
2176
+ *
2177
+ * [1.6.0] 新增 ended 分组:宿主已经 `turn/end`(会话这一轮结束、没有任何
2178
+ * 东西在跑),而计划还没做完的,一律进「已结束」,绝不进「进行中」。
2179
+ * 这正是本次事故的现象:会话结束 4 小时后仍显示「进行中」。
2096
2180
  */
2097
2181
  for (const session of activeSessions) {
2098
- if (planPhaseOf(session.phase, planCounts(session.stats)) === 'done')
2182
+ const phase = planPhaseOf(session.phase, planCounts(session.stats));
2183
+ if (phase === 'done')
2099
2184
  finished.push(session);
2185
+ else if (phase === 'ended')
2186
+ ended.push(session);
2100
2187
  else
2101
2188
  live.push(session);
2102
2189
  }
@@ -2114,11 +2201,19 @@ window.__ModuleLoader__.load({
2114
2201
  integrating: 3,
2115
2202
  planning: 4,
2116
2203
  pending: 5,
2204
+ ended: 6,
2117
2205
  };
2118
2206
  const rank = (session) => phaseRank[planPhaseOf(session.phase, planCounts(session.stats))] ?? 5;
2119
2207
  live.sort((a, b) => (rank(a) - rank(b))
2120
2208
  || ((Number(b.createdAt) || 0) - (Number(a.createdAt) || 0))
2121
2209
  || String(a.sessionId).localeCompare(String(b.sessionId)));
2210
+ /*
2211
+ * [1.6.0] 已结束组按「最近结束在前」:`endedAt` 是宿主 turn/end 的时间戳
2212
+ * (后端下发),比 updatedAt 更准确地表达「什么时候停的」。
2213
+ */
2214
+ const endedAt = (session) => Number(session.endedAt) || Number(session.updatedAt) || Number(session.createdAt) || 0;
2215
+ ended.sort((a, b) => (endedAt(b) - endedAt(a))
2216
+ || ((Number(b.createdAt) || 0) - (Number(a.createdAt) || 0)));
2122
2217
  /*
2123
2218
  * 已完成组按「最近完成在前」(§3.3 / C8):优先取子任务
2124
2219
  * statuses[].finishedAt 的最大值(忽略 null / 非数字),缺失则退回
@@ -2144,9 +2239,20 @@ window.__ModuleLoader__.load({
2144
2239
  };
2145
2240
  finished.sort((a, b) => (finishedAt(b) - finishedAt(a))
2146
2241
  || ((Number(b.createdAt) || 0) - (Number(a.createdAt) || 0)));
2147
- return { live, finished, urgent: live.filter((session) => urgentPhases.includes(session.phase)).length };
2242
+ return {
2243
+ live,
2244
+ ended,
2245
+ finished,
2246
+ urgent: live.filter((session) => urgentPhases.includes(session.phase)).length,
2247
+ /*
2248
+ * [1.6.0] 「已结束」组也需要「需处理」角标:卡住的计划停了仍然是卡住的,
2249
+ * 判定用后端下发的 suspendedPhase(原派发阶段),而不是被收敛后的 ended。
2250
+ */
2251
+ urgentEnded: ended.filter((session) => urgentPhases.includes(String(session.suspendedPhase ?? ''))).length,
2252
+ };
2148
2253
  }, [activeSessions]);
2149
- const liveBars = useMemo(() => groups.live.slice(0, 6).map((session) => {
2254
+ // [1.6.0] 图表口径 = 未结束计划(进行中 + 已结束未完成),与环图标签一致。
2255
+ const liveBars = useMemo(() => [...groups.live, ...groups.ended].slice(0, 6).map((session) => {
2150
2256
  const raw = String(session.title || t('panel'));
2151
2257
  return {
2152
2258
  label: raw.length > 14 ? `${raw.slice(0, 14)}…` : raw,
@@ -2154,16 +2260,77 @@ window.__ModuleLoader__.load({
2154
2260
  value: planPercent(planCount(session.stats?.done), planCount(session.stats?.total)) ?? 0,
2155
2261
  };
2156
2262
  }), [groups, t]);
2157
- return h('div', { className: 'dsh-wp' }, h('header', { className: 'dsh-wp-header' }, h('div', null, h('h1', { className: 'dsh-wp-title' }, t('title')), h('p', { className: 'dsh-wp-subtitle' }, t('subtitle')), h('div', { className: 'dsh-wp-meta' }, updatedAt ? h('span', null, `${t('updatedAt')} ${formatTime(updatedAt)}`) : null, h('span', null, `${t('scopeAll')}:${activeSessions.length} ${t('sessionCount')},${t('taskBreakdown')} ${totals.total} ${t('subtaskCount')}`))), h('button', { type: 'button', className: 'dsh-wp-button', onClick: reload, disabled: loading }, t('refresh'))), error ? h(ErrorBanner, { message: error, onRetry: reload, t }) : null, activeSessions.length > 0 ? h('div', { className: 'dsh-wp-statbar', role: 'list' }, h('div', { className: 'dsh-wp-stat dsh-wp-stat--tasks', role: 'listitem' }, h('div', { className: 'dsh-wp-stat-value' }, activeSessions.length), h('div', { className: 'dsh-wp-stat-label' }, t('sessionCount'))), h('div', { className: 'dsh-wp-stat', role: 'listitem' }, h('div', { className: 'dsh-wp-stat-value' }, totals.total), h('div', { className: 'dsh-wp-stat-label' }, t('workItems'))), h('div', { className: 'dsh-wp-stat dsh-wp-stat--done', role: 'listitem' }, h('div', { className: 'dsh-wp-stat-value' }, totals.done), h('div', { className: 'dsh-wp-stat-label' }, t('stats.done'))), h('div', { className: 'dsh-wp-stat dsh-wp-stat--active', role: 'listitem' }, h('div', { className: 'dsh-wp-stat-value' }, totals.inProgress), h('div', { className: 'dsh-wp-stat-label' }, t('stats.inProgress'))), h('div', { className: 'dsh-wp-stat dsh-wp-stat--blocked', role: 'listitem' }, h('div', { className: 'dsh-wp-stat-value' }, totals.blocked), h('div', { className: 'dsh-wp-stat-label' }, t('stats.blocked')))) : null, activeSessions.length > 0 ? h('div', { className: 'dsh-wp-scope-note' }, t('allPlansHint')) : null, activeSessions.length === 0
2263
+ /*
2264
+ * [T4] 回到顶部:用「状态当 ref」拿面板根节点(宿主兼容层不保证 useRef,
2265
+ * 见 GroupCharts 的同一处理),滚动目标只能是 .dsh-wp 这个 overflow 容器。
2266
+ */
2267
+ const [panelEl, setPanelEl] = useState(null);
2268
+ const [showBackTop, setShowBackTop] = useState(false);
2269
+ useEffect(() => {
2270
+ const panel = panelEl;
2271
+ if (!panel || typeof panel.addEventListener !== 'function')
2272
+ return;
2273
+ const onScroll = () => setShowBackTop(Number(panel.scrollTop) > BACK_TOP_THRESHOLD);
2274
+ // 挂载与内容变化时先求一次初值:刷新后停在中间也必须显示按钮。
2275
+ onScroll();
2276
+ panel.addEventListener('scroll', onScroll, { passive: true });
2277
+ return () => panel.removeEventListener('scroll', onScroll);
2278
+ }, [panelEl, activeSessions.length]);
2279
+ const backToTop = useCallback((event) => {
2280
+ // 双保险:ref 尚未回填时,从事件目标向上找唯一的滚动容器。
2281
+ let panel = panelEl;
2282
+ if (!panel && event && event.currentTarget && typeof event.currentTarget.closest === 'function') {
2283
+ panel = event.currentTarget.closest('.dsh-wp');
2284
+ }
2285
+ if (!panel)
2286
+ return;
2287
+ const reduced = typeof window !== 'undefined' && typeof window.matchMedia === 'function'
2288
+ && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
2289
+ if (typeof panel.scrollTo === 'function') {
2290
+ try {
2291
+ panel.scrollTo({ top: 0, behavior: reduced ? 'auto' : 'smooth' });
2292
+ return;
2293
+ }
2294
+ catch (error) {
2295
+ /* 旧宿主不支持带参数的 scrollTo:落到下面的直接赋值。 */
2296
+ }
2297
+ }
2298
+ panel.scrollTop = 0;
2299
+ }, [panelEl]);
2300
+ return h('div', {
2301
+ className: 'dsh-wp',
2302
+ ref: (node) => { if (node !== panelEl)
2303
+ setPanelEl(node); },
2304
+ }, h('header', { className: 'dsh-wp-header' }, h('div', null, h('h1', { className: 'dsh-wp-title' }, t('title')), h('p', { className: 'dsh-wp-subtitle' }, t('subtitle')), h('div', { className: 'dsh-wp-meta' }, updatedAt ? h('span', null, `${t('updatedAt')} ${formatTime(updatedAt)}`) : null, h('span', null, `${t('scopeAll')}:${activeSessions.length} ${t('sessionCount')},${t('taskBreakdown')} ${totals.total} ${t('subtaskCount')}`))), h('button', { type: 'button', className: 'dsh-wp-button', onClick: reload, disabled: loading }, t('refresh'))), error ? h(ErrorBanner, { message: error, onRetry: reload, t }) : null, activeSessions.length > 0 ? h('div', { className: 'dsh-wp-statbar', role: 'list' }, h('div', { className: 'dsh-wp-stat dsh-wp-stat--tasks', role: 'listitem' }, h('div', { className: 'dsh-wp-stat-value' }, activeSessions.length), h('div', { className: 'dsh-wp-stat-label' }, t('sessionCount'))), h('div', { className: 'dsh-wp-stat', role: 'listitem' }, h('div', { className: 'dsh-wp-stat-value' }, totals.total), h('div', { className: 'dsh-wp-stat-label' }, t('workItems'))), h('div', { className: 'dsh-wp-stat dsh-wp-stat--done', role: 'listitem' }, h('div', { className: 'dsh-wp-stat-value' }, totals.done), h('div', { className: 'dsh-wp-stat-label' }, t('stats.done'))), h('div', { className: 'dsh-wp-stat dsh-wp-stat--active', role: 'listitem' }, h('div', { className: 'dsh-wp-stat-value' }, totals.inProgress), h('div', { className: 'dsh-wp-stat-label' }, t('stats.inProgress'))), h('div', { className: 'dsh-wp-stat dsh-wp-stat--blocked', role: 'listitem' }, h('div', { className: 'dsh-wp-stat-value' }, totals.blocked), h('div', { className: 'dsh-wp-stat-label' }, t('stats.blocked')))) : null, activeSessions.length > 0 ? h('div', { className: 'dsh-wp-scope-note' }, t('allPlansHint')) : null, activeSessions.length === 0
2158
2305
  ? h('div', { className: 'dsh-wp-empty' }, h('div', { style: { fontWeight: 650, marginBottom: '4px' } }, t('empty')), h('div', null, t('emptyHint')))
2159
- : h('div', { className: 'dsh-wp-groups' }, h(SessionGroup, { group: 'live', list: groups.live, urgent: groups.urgent, t, openSessionId, setOpenSessionId }), h(SessionGroup, { group: 'done', list: groups.finished, hasLive: groups.live.length > 0, urgent: 0, t, openSessionId, setOpenSessionId }),
2160
- // 用户选择 B:总览块(完成率环 + 每个计划的进度条)同样下移到两组之后,
2161
- // 让开屏第一屏直接是「进行中」组的任务卡(此前统计条 → 总览 → 说明行 →
2162
- // 任务卡,第一张卡要下滑约一屏)。顶部只保留 5 格数字统计条与一行口径说明。
2306
+ : h('div', { className: 'dsh-wp-groups' },
2307
+ // [用户要求] 总览块(完成率环 + 每个任务的进度)上移到分组之前:
2308
+ // 用户要求红圈的「每个任务的进度」必须显示在「进行中」组之上。
2163
2309
  activeSessions.length > 0 ? h('div', { className: 'dsh-wp-overview' }, h(Donut, { totals, t }), h(TaskBars, { sessions: activeSessions, t, onSelect: selectSession })) : null,
2310
+ /*
2311
+ * [1.6.0] 三组顺序:真的在跑 → 已结束(停在半路) → 已完成。
2312
+ * 「已结束」夹在中间是有意为之:它是用户最需要立刻知道的那一档
2313
+ * (刚停、还没做完),不能滑到历史组的下面去。
2314
+ */
2315
+ h(SessionGroup, { key: 'live', group: 'live', list: groups.live, urgent: groups.urgent, t, openSessionId, setOpenSessionId }), groups.ended.length > 0
2316
+ ? h(SessionGroup, { key: 'ended', group: 'ended', list: groups.ended, hasLive: groups.live.length > 0, urgent: groups.urgentEnded, t, openSessionId, setOpenSessionId })
2317
+ : null, h(SessionGroup, { key: 'done', group: 'done', list: groups.finished, hasLive: groups.live.length > 0 || groups.ended.length > 0, urgent: 0, t, openSessionId, setOpenSessionId }),
2164
2318
  // 图表放两组之后:两张卡各 ≈246px,排在组前会让首屏看不到任何一张任务卡
2165
2319
  // (设计稿 §8 第 12 条,T8 复核时复现在 1.4.2 源码里)。
2166
- h(GroupCharts, { liveCount: groups.live.length, doneCount: groups.finished.length, liveBars, hiddenBars: Math.max(0, groups.live.length - 6), t })));
2320
+ // [1.6.0] 「未结束」= 进行中 + 已结束但未完成:两者都还没做完,都是用户要盯的对象。
2321
+ h(GroupCharts, { liveCount: groups.live.length + groups.ended.length, doneCount: groups.finished.length, liveBars, hiddenBars: Math.max(0, groups.live.length + groups.ended.length - 6), t })),
2322
+ /*
2323
+ * [T4] 始终挂载的回到顶部按钮:作为 .dsh-wp 的最后一个直接子元素,
2324
+ * sticky 在面板滚动视口右下角;显隐只切换 data-visible,不增删节点。
2325
+ */
2326
+ h('button', {
2327
+ type: 'button',
2328
+ className: 'dsh-wp-backtop',
2329
+ 'data-visible': showBackTop ? 'true' : 'false',
2330
+ 'aria-label': t('backToTop'),
2331
+ title: t('backToTop'),
2332
+ onClick: backToTop,
2333
+ }, h('span', { 'aria-hidden': 'true' }, '↑')));
2167
2334
  }
2168
2335
  function TurnCard({ sessionId, turn, t }) {
2169
2336
  const { sessions } = usePlans(sessionId);
@@ -2188,7 +2355,7 @@ window.__ModuleLoader__.load({
2188
2355
  const stats = session.stats || {};
2189
2356
  const phase = planPhaseOf(session.phase || 'pending', planCounts(stats));
2190
2357
  const tone = phaseTone(phase);
2191
- return h('div', { className: `dsh-wp-turn dsh-wp-tone-${tone}` }, h('div', { className: 'dsh-wp-turn-title' }, h('span', null, session.title || t('panel')), h(Pill, { tone }, t(`phase.${phase}`))), h('div', { className: 'dsh-wp-muted', style: { marginTop: '6px' } }, `${t('helpWho')}:${workerText(session, t)}`), h('div', { className: 'dsh-wp-muted', style: { marginTop: '2px' } }, `${t('helpNext')}:${nextText(session, t)}`), h('div', { className: 'dsh-wp-progress-meta' }, h('span', null, `${stats.done ?? 0}/${stats.total ?? 0} ${t('stats.done')} · ${stats.blocked ?? 0} ${t('stats.blocked')}`), h('span', { className: 'dsh-wp-muted' }, t('viewHint'))));
2358
+ return h('div', { className: `dsh-wp-turn dsh-wp-tone-${tone}` }, h('div', { className: 'dsh-wp-turn-title' }, h('span', null, session.title || t('panel')), h(Pill, { tone }, phaseLabel(phase, session, t))), h('div', { className: 'dsh-wp-muted', style: { marginTop: '6px' } }, `${t('helpWho')}:${workerText(session, t)}`), h('div', { className: 'dsh-wp-muted', style: { marginTop: '2px' } }, `${t('helpNext')}:${nextText(session, t)}`), h('div', { className: 'dsh-wp-progress-meta' }, h('span', null, `${stats.done ?? 0}/${stats.total ?? 0} ${t('stats.done')} · ${stats.blocked ?? 0} ${t('stats.blocked')}`), h('span', { className: 'dsh-wp-muted' }, t('viewHint'))));
2192
2359
  }
2193
2360
  function contentText(block) {
2194
2361
  if (!block || !Array.isArray(block.content))
package/lib/host.js CHANGED
@@ -8,7 +8,7 @@ import { readFileSync } from 'node:fs';
8
8
  * - dsh_workplan_update and dsh_workplan_dispatch model tools;
9
9
  * - the read-only dashboard route.
10
10
  */
11
- import { createWorkplanRuntime, dispatchToolOutputSchema, plannerOutputSchema, updateToolOutputSchema, } from './runtime.js';
11
+ import { createWorkplanRuntime, dispatchToolOutputSchema, plannerOutputSchema, statusToolOutputSchema, updateToolOutputSchema, } from './runtime.js';
12
12
  import { isRecord } from './plan.js';
13
13
  function phaseLabel(phase) {
14
14
  if (phase === 'paused')
@@ -31,7 +31,7 @@ export const name = 'dsh-workplan';
31
31
  export const inject = ['tools', 'systemPrompt', 'llm', 'subagents', 'sessions'];
32
32
  export const PROMPT_ORDER = 40;
33
33
  const PROMPT_SECTION = [
34
- '本会话已启用自动任务分解。系统会在每个新用户任务的第一个模型步骤前生成计划,并先把计划显示在对话里;收到【任务分解】后,必须先调用 dsh_workplan_dispatch,等它返回部门执行结果,再做任何其他工具调用或回答。',
34
+ '本会话已启用自动任务分解。系统会在每个新用户任务的第一个模型步骤前生成计划,并先把计划显示在对话里;收到【任务分解】后,必须先调用 dsh_workplan_dispatch(默认 wait 等结果;预计较久时用 mode:"async" 先开跑),再做任何其他工具调用或回答。',
35
35
  '如果当前是 plan 模式:不要调用 dsh_workplan_dispatch;先把计划展示给用户,等待用户审阅并退出 plan 模式后,再调用 dsh_workplan_dispatch 执行。',
36
36
  '纯问候、寒暄、致谢、告别、简单确认(如「你好」「谢谢」「好的」「再见」)不生成计划,也不启动子 Agent;直接自然、简短地回答。只有包含实际目标、问题或交付物的消息才进行分解。',
37
37
  '单独的「继续」「接着」「然后呢」「下一步」等没有新增任务内容的追问,不生成计划;由主 Agent 结合会话上下文继续,或先询问用户要延续哪件事。',
@@ -41,8 +41,25 @@ const PROMPT_SECTION = [
41
41
  '2. 核对每个完成子任务的证据与验收标准,不合格的要用 dsh_workplan_update 标记为 blocked 或 in_progress;',
42
42
  '3. 对受阻项向用户说明,必要时先询问再继续;',
43
43
  '4. 不要声称未经验证的完成,不要重复派发已完成的子任务。',
44
+ '结果消息里每个完成项都带 verification 与 acceptance:`structured` 是子 Agent 逐条自检通过,`unverified` 是自述但未逐条确认,`failed` 是自检失败(已按受阻处理),`legacy` 是旧格式回传。只把 structured 当作可直接采信,其余必须你自己核对产物。',
45
+ '子 Agent 通过 `needs` 提出的跨部门需求会列在结果消息的「跨部门待转达」里:由你逐条处理(补派、向用户确认或直接完成),不要忽略。',
46
+ '长任务可以用 `dsh_workplan_dispatch({ mode: "async" })` 先开跑并立即答复用户,再用 `dsh_workplan_status` 查看进度;async 返回的是“已开跑”,不是“已完成”。',
44
47
  '如果自动分解降级,先向用户说明失败原因并询问是否重试,在用户确认前不要开始执行任务。',
45
48
  ].join('\n');
49
+ /**
50
+ * Seconds a dispatch has been running, from the payload only.
51
+ *
52
+ * `elapsedMs` is authoritative; `startedAt` is the fallback for a payload that
53
+ * carries no elapsed value. Computing this inside the template mixed `??` with
54
+ * a conditional and could silently print the wrong number.
55
+ */
56
+ function elapsedSeconds(result) {
57
+ const elapsed = Number(result?.elapsedMs);
58
+ if (Number.isFinite(elapsed) && elapsed >= 0)
59
+ return elapsed;
60
+ const startedAt = Number(result?.startedAt);
61
+ return Number.isFinite(startedAt) && startedAt > 0 ? Date.now() - startedAt : 0;
62
+ }
46
63
  function textContent(text) {
47
64
  return [{ type: 'text', text }];
48
65
  }
@@ -92,6 +109,14 @@ function createUpdateTool(runtime) {
92
109
  items: { type: 'string' },
93
110
  description: '支持该状态的证据(文件、命令输出、验收结果)。',
94
111
  },
112
+ expectedRevision: {
113
+ type: 'integer',
114
+ description: '你读取到的 revision。传入后若该子任务已被更新,会返回 STALE_WRITE 而不是覆盖新证据。',
115
+ },
116
+ force: {
117
+ type: 'boolean',
118
+ description: '计划执行中强行改判(默认拒绝并返回 TASK_RUNNING)。会记录为人工改判。',
119
+ },
95
120
  note: {
96
121
  type: 'string',
97
122
  description: '补充说明;会显示在任务卡片中。',
@@ -108,7 +133,7 @@ function createUpdateTool(runtime) {
108
133
  const text = result.ok
109
134
  ? `已更新子任务 ${String(result.subtaskId ?? '')}:${String(result.status ?? '')}`
110
135
  + `(完成 ${Number(stats.done ?? 0)}/${Number(stats.total ?? 0)},受阻 ${Number(stats.blocked ?? 0)})`
111
- : `更新失败:${String(result.error ?? '未知错误')}`;
136
+ : `更新失败${result.code ? `(${String(result.code)})` : ''}:${String(result.error ?? result.hint ?? '未知错误')}`;
112
137
  return textContent(text);
113
138
  },
114
139
  },
@@ -167,6 +192,43 @@ function createCancelTool(runtime) {
167
192
  },
168
193
  };
169
194
  }
195
+ function createStatusTool(runtime) {
196
+ return {
197
+ name: 'dsh_workplan_status',
198
+ description: '只读查看当前计划各子任务的实时状态与进度,不启动任何 Agent、不改任何状态。'
199
+ + '在 async 派发之后、或用户问“做到哪了”时使用;它是进度问题的唯一可信来源。',
200
+ parameters: {
201
+ type: 'object',
202
+ properties: {
203
+ planId: {
204
+ type: 'string',
205
+ description: '计划 ID;省略时使用当前会话最新计划。',
206
+ },
207
+ },
208
+ additionalProperties: false,
209
+ },
210
+ output: {
211
+ schema: statusToolOutputSchema(),
212
+ render(_args, value) {
213
+ const result = isRecord(value) ? value : {};
214
+ const stats = isRecord(result.stats) ? result.stats : {};
215
+ if (!result.ok)
216
+ return textContent(`查询失败:${String(result.error ?? '未知错误')}`);
217
+ const running = result.running === true;
218
+ return textContent(`计划 ${String(result.planId ?? '')}|${running ? '执行中' : '未在执行'}`
219
+ + `|阶段:${phaseLabel(result.phase)}`
220
+ + `|完成 ${Number(stats.done ?? 0)}/${Number(stats.total ?? 0)},受阻 ${Number(stats.blocked ?? 0)}`
221
+ + (running && Number(result.elapsedMs ?? 0) > 0
222
+ ? `|已 ${Math.round(Number(result.elapsedMs) / 1000)}s`
223
+ : ''));
224
+ },
225
+ },
226
+ async execute(args, exec) {
227
+ const parsed = asObject(args) ?? {};
228
+ return runtime.statusTool(exec.agent, parsed);
229
+ },
230
+ };
231
+ }
170
232
  function createDispatchTool(runtime) {
171
233
  return {
172
234
  name: 'dsh_workplan_dispatch',
@@ -179,6 +241,12 @@ function createDispatchTool(runtime) {
179
241
  type: 'string',
180
242
  description: '计划 ID;省略时使用当前会话最新计划。',
181
243
  },
244
+ mode: {
245
+ type: 'string',
246
+ enum: ['wait', 'async'],
247
+ description: '默认 wait:等本轮结束后返回完整结果。async:立即返回 running,'
248
+ + '本轮结束时自动写入结果消息;期间用 dsh_workplan_status 查看进度。',
249
+ },
182
250
  },
183
251
  additionalProperties: false,
184
252
  },
@@ -190,7 +258,10 @@ function createDispatchTool(runtime) {
190
258
  return textContent(result.ok
191
259
  ? `计划 ${String(result.planId ?? '')} 当前阶段:${phaseLabel(result.phase)}`
192
260
  + `(完成 ${Number(stats.done ?? 0)}/${Number(stats.total ?? 0)},受阻 ${Number(stats.blocked ?? 0)})`
193
- + (result.alreadyRunning ? `|仍在执行(已 ${Math.round(Number(result.elapsedMs ?? 0) / 1000)}s)` : '')
261
+ + (result.alreadyRunning || result.mode === 'async'
262
+ ? `|已在执行(${Math.round(elapsedSeconds(result) / 1000)}s)`
263
+ : '')
264
+ + (result.joined ? '|已加入进行中的派发并等到结果' : '')
194
265
  // The hint carries the recovery instruction (resume, or take the work
195
266
  // over directly); showing it in the rendered line keeps it visible
196
267
  // even when only the summary is read.
@@ -243,6 +314,7 @@ export function apply(ctx, config = {}) {
243
314
  }));
244
315
  ctx.effect(() => ctx.tools.register(createUpdateTool(runtime)));
245
316
  ctx.effect(() => ctx.tools.register(createCancelTool(runtime)));
317
+ ctx.effect(() => ctx.tools.register(createStatusTool(runtime)));
246
318
  ctx.effect(() => ctx.tools.register(createDispatchTool(runtime)));
247
319
  /*
248
320
  * Plan mode produces a plan for review, not department execution. Denying
@@ -294,8 +366,8 @@ export function apply(ctx, config = {}) {
294
366
  }
295
367
  export const meta = {
296
368
  name,
297
- version: '1.5.2',
369
+ version: '1.7.0',
298
370
  promptOrder: PROMPT_ORDER,
299
371
  routes: ['/dsh-workplan/plans', '/dsh-workplan/vendor/chart.umd.js'],
300
372
  };
301
- export { PROMPT_SECTION, createCancelTool, createDispatchTool, createUpdateTool, plannerOutputSchema };
373
+ export { PROMPT_SECTION, createCancelTool, createDispatchTool, createStatusTool, createUpdateTool, plannerOutputSchema };