dsh-dispatch-board 0.2.0 → 0.2.2

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/lib/client.js CHANGED
@@ -57,6 +57,8 @@ window.__ModuleLoader__.load({
57
57
  doing: '#f0a24a',
58
58
  done: '#22b573',
59
59
  archived: '#98a2b3',
60
+ // v0.2.2:「待你处理」不是 status,只作为第五列的强调色(红)。
61
+ needsUser: '#e5484d',
60
62
  }
61
63
 
62
64
  /* ══════════════════════════════════════════════════════════════
@@ -111,7 +113,10 @@ window.__ModuleLoader__.load({
111
113
  '.tb-board{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px;align-items:stretch;min-width:0;flex:1 0 auto;min-height:240px}',
112
114
  '.tb-col{display:flex;flex-direction:column;gap:8px;min-width:0;background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-md);padding:9px 9px 11px;min-height:220px;height:100%}',
113
115
  '.tb-col[data-status=archived]{opacity:.92}',
114
- '.tb-colhead{display:flex;align-items:center;gap:7px;padding:1px 1px 5px;border-bottom:1px solid var(--dsw-alias-border-l1)}',
116
+ '.tb-colhead{display:flex;align-items:center;gap:7px;padding:1px 1px 5px;border-bottom:1px solid var(--dsw-alias-border-l1);height:31px;box-sizing:border-box}',
117
+ // 列头高度固定:只有「已完成」列带「全部归档」按钮(24px 高),其它列只有文字(14px 行高)。
118
+ // 不固定时 flex 行高被按钮撑大 ~10px,导致「已完成」标题和整列卡片都比别的列低一截。
119
+ '.tb-page[data-narrow=true] .tb-colhead{height:29px}',
115
120
  '.tb-coldot{width:8px;height:8px;border-radius:50%;flex:0 0 auto;background:var(--tb-accent)}',
116
121
  '.tb-colname{font:var(--dsw-font-xxs-strong-12);font-weight:600;letter-spacing:.01em}',
117
122
  '.tb-colcount{min-width:18px;height:18px;padding:0 5px;display:inline-flex;align-items:center;justify-content:center;border-radius:999px;background:color-mix(in srgb,var(--tb-accent) 16%,transparent);color:var(--tb-accent);font:var(--dsw-font-xxxs-strong-11);font-variant-numeric:tabular-nums}',
@@ -265,6 +270,38 @@ window.__ModuleLoader__.load({
265
270
  '.tb-page[data-narrow=true] .tb-lead-label{max-width:160px}',
266
271
 
267
272
 
273
+ // ── 待你处理(v0.2.2,§1.9)────────────────────────────────
274
+ // 右栏顶部条:只在有 flagged 任务时渲染;这些任务不重复出现在下面的 lane / 四列。
275
+ '.tb-needs{position:sticky;top:0;z-index:3;display:flex;flex-direction:column;gap:6px;padding:9px 10px;border:1px solid color-mix(in srgb,var(--dsw-alias-state-error-primary) 38%,transparent);border-radius:var(--dsw-radius-md);background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 7%,var(--dsw-alias-bg-base))}',
276
+ '.tb-needs-head{display:flex;align-items:center;gap:6px}',
277
+ '.tb-needs-dot{width:7px;height:7px;border-radius:50%;background:var(--dsw-alias-state-error-primary);flex:0 0 auto}',
278
+ '.tb-needs-name{font:var(--dsw-font-xxs-strong-12);font-weight:600}',
279
+ '.tb-needs-count{min-width:18px;height:18px;padding:0 5px;display:inline-flex;align-items:center;justify-content:center;border-radius:999px;background:var(--dsw-alias-state-error-primary);color:var(--dsw-alias-label-primary-foreground);font:var(--dsw-font-xxxs-strong-11);font-variant-numeric:tabular-nums}',
280
+ '.tb-needs-list{display:flex;flex-direction:column;gap:4px}',
281
+ '.tb-needs-item{display:flex;flex-direction:column;gap:1px;width:100%;padding:5px 7px;text-align:left;border:0;border-radius:var(--dsw-radius-sm);background:transparent;color:var(--dsw-alias-label-primary);cursor:pointer;font:inherit}',
282
+ '.tb-needs-item:hover{background:var(--dsw-alias-interactive-bg-hover)}',
283
+ '.tb-needs-item:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}',
284
+ '.tb-needs-title{font:var(--dsw-font-xxs-strong-12);font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
285
+ '.tb-needs-q{font:var(--dsw-font-xxxs-11);color:var(--dsw-alias-label-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
286
+ // 平台看板第五列(放在「待开始」之前;没有 flagged 任务时整列不渲染,仍是四列)。
287
+ '.tb-board[data-needs=true]{grid-template-columns:repeat(5,minmax(0,1fr))}',
288
+ '.tb-col[data-status=needsUser]{border:1px solid color-mix(in srgb,var(--dsw-alias-state-error-primary) 30%,transparent);border-radius:var(--dsw-radius-md);padding:9px 9px 11px;background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 5%,var(--dsw-alias-bg-layer-1))}',
289
+ '.tb-needs-card-q{margin:4px 0 0;font:var(--dsw-font-xxxs-11);line-height:1.5;color:var(--dsw-alias-label-secondary);display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;word-break:break-word}',
290
+ '.tb-needs-card .tb-card-actions{margin-top:6px}',
291
+ // 详情浮层的「需要你处理」区(问题 / 选项 / 自由输入 / 回复并继续 / 最近回答)。
292
+ '.tb-detail-needs{border:1px solid color-mix(in srgb,var(--dsw-alias-state-error-primary) 35%,transparent);border-radius:var(--dsw-radius-md);padding:9px 11px;background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 6%,transparent);gap:7px}',
293
+ '.tb-needs-question{margin:0;font:var(--dsw-font-xs-12);line-height:1.6;white-space:pre-wrap;word-break:break-word}',
294
+ '.tb-needs-options{display:flex;flex-wrap:wrap;gap:6px}',
295
+ '.tb-answer{min-height:60px;height:auto}',
296
+ '.tb-detail-needs-actions{display:flex;justify-content:flex-end;gap:8px}',
297
+ '.tb-needs-error{margin:0;font:var(--dsw-font-xxxs-11);color:var(--dsw-alias-state-error-primary)}',
298
+ '.tb-needs-hint{margin:0;font:var(--dsw-font-xxxs-11);color:var(--dsw-alias-label-tertiary)}',
299
+ '.tb-detail-lastanswer{margin:0;padding:6px 8px;border-radius:6px;background:var(--dsw-alias-bg-skeleton);font:var(--dsw-font-xxxs-11);color:var(--dsw-alias-label-secondary);white-space:pre-wrap;word-break:break-word}',
300
+ // 独立红色角标:与 todo 角标同一形状,放在按钮 / 图标的另一角,不抢 todo 数字。
301
+ '.tb-badge-needs{top:auto;bottom:-3px;right:-5px;background:var(--dsw-alias-state-error-primary);color:var(--dsw-alias-label-primary-foreground)}',
302
+ '.tb-page[data-layout=narrow] .tb-needs{padding:7px 8px}',
303
+ '.tb-page[data-layout=narrow] .tb-needs-item{padding:4px 5px}',
304
+
268
305
  // ── Apple 风格皮肤(最后追加,覆盖上面的基础样式)──────────
269
306
  // 设计参照 macOS / iOS:灰色画布 + 白色卡片、发丝分隔线、胶囊按钮、系统字体、柔和阴影。
270
307
  // 颜色全部走宿主主题 token,深色模式自动跟随。
@@ -370,13 +407,16 @@ window.__ModuleLoader__.load({
370
407
  '.tb-rich a{color:var(--dsw-alias-link,var(--tb-accent));text-decoration:none}',
371
408
  '.tb-rich a:hover{text-decoration:underline}',
372
409
 
373
- // ── 卡片精简 + 等高(t-33)──────────────────────────────────
374
- // 卡片正文只剩标题,操作行固定贴底;高度统一用 min-height 兜住(--tb-card-h),
375
- // 标题 / 按钮数量不同的卡片视觉等高,按钮行不会被固定高度裁掉。
376
- // 标题 2 行截断(line-clamp),全文放 title 属性;行内编辑态不带 .tb-card-fixed,高度自适应。
377
- '.tb-card-fixed{min-height:var(--tb-card-h,108px);gap:5px;padding:9px 10px 8px}',
378
- '.tb-card-fixed .tb-card-title{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;line-height:1.4;word-break:break-word}',
379
- '.tb-card-fixed .tb-card-actions{margin-top:auto;gap:3px 4px;padding-top:0}',
410
+ // ── 卡片精简 + 等高(t-33 / t-42)────────────────────────────
411
+ // 卡片正文只剩标题,高度由内容决定(t-42 去掉了整卡 min-height:108px + 操作行
412
+ // margin-top:auto——那两条会把 2 行标题的卡片撑高,多余高度全变成标题与按钮之间的空行)。
413
+ // 等高改用「标题固定 2 行高度」:1 行标题与 2 行标题的标题块都是 2.8em(12.5px × 1.4 × 2
414
+ // = 35px),标题与操作行之间只留 .tb-card-fixed 的 gap:5px,不再有整块空行。
415
+ // 窄栏按钮换 2 行时卡片会变高(不裁按钮的取舍);标题 2 行截断(line-clamp),
416
+ // 全文放 title 属性;行内编辑态不带 .tb-card-fixed,高度自适应。
417
+ '.tb-card-fixed{gap:5px;padding:9px 10px 8px}',
418
+ '.tb-card-fixed .tb-card-title{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;min-height:2.8em;line-height:1.4;word-break:break-word}',
419
+ '.tb-card-fixed .tb-card-actions{gap:3px 4px;padding-top:0}',
380
420
  '.tb-card-fixed .tb-card-actions .tb-btn{height:22px;padding:0 7px;font-size:10.5px}',
381
421
  ].join('\n')
382
422
 
@@ -465,6 +505,7 @@ window.__ModuleLoader__.load({
465
505
  'detail.sessions': '关联对话',
466
506
  'detail.creatorSession': '发起对话',
467
507
  'detail.runSession': '执行对话',
508
+ 'detail.leadSession': '组长对话',
468
509
  'detail.noSession': '(这条任务还没有关联对话)',
469
510
  'detail.basicInfo': '基本信息',
470
511
  'detail.timeline': '时间线',
@@ -560,6 +601,21 @@ window.__ModuleLoader__.load({
560
601
  'lead.ensureOk': '已创建工作区组长',
561
602
  'detail.lead': '组长',
562
603
  'detail.noLead': '(还没有组长)',
604
+
605
+ // v0.2.2「待你处理」(§1.9):组长提问 → 看板提示 → 用户回答 → 任务继续
606
+ 'column.needsUser': '待你处理',
607
+ 'needsUser.title': '需要你处理',
608
+ 'needsUser.question': '需要你回答的问题',
609
+ 'needsUser.answerPlaceholder': '输入你的回答(≤{max} 字)…',
610
+ 'needsUser.submit': '回复并继续',
611
+ 'needsUser.badge': '{n} 条待你处理',
612
+ 'needsUser.open': '处理',
613
+ 'needsUser.lastAnswer': '最近回答',
614
+ 'needsUser.answerOk': '已回复,任务继续处理',
615
+ 'needsUser.answerFailed': '回复发送失败:{message}',
616
+ 'needsUser.answerEmpty': '先写回答再提交',
617
+ 'needsUser.answerTooLong': '回答不能超过 {max} 字',
618
+ 'needsUser.pickOption': '点上面的选项可以填入输入框,也可以自己写。',
563
619
  }
564
620
 
565
621
  const DICT_EN = {
@@ -632,6 +688,7 @@ window.__ModuleLoader__.load({
632
688
  'detail.sessions': 'Linked conversations',
633
689
  'detail.creatorSession': 'Created in',
634
690
  'detail.runSession': 'Dispatched to',
691
+ 'detail.leadSession': 'Lead conversation',
635
692
  'detail.noSession': '(this task has no linked conversation yet)',
636
693
  'detail.basicInfo': 'Details',
637
694
  'detail.timeline': 'Timeline',
@@ -727,6 +784,21 @@ window.__ModuleLoader__.load({
727
784
  'lead.ensureOk': 'Workspace lead created',
728
785
  'detail.lead': 'Lead',
729
786
  'detail.noLead': '(no lead yet)',
787
+
788
+ // v0.2.2 needs-user loop (§1.9)
789
+ 'column.needsUser': 'Needs you',
790
+ 'needsUser.title': 'Needs your answer',
791
+ 'needsUser.question': 'Question for you',
792
+ 'needsUser.answerPlaceholder': 'Type your answer (≤{max} chars)…',
793
+ 'needsUser.submit': 'Reply and continue',
794
+ 'needsUser.badge': '{n} waiting for you',
795
+ 'needsUser.open': 'Answer',
796
+ 'needsUser.lastAnswer': 'Last answer',
797
+ 'needsUser.answerOk': 'Answer sent; the task continues',
798
+ 'needsUser.answerFailed': 'Could not send the answer: {message}',
799
+ 'needsUser.answerEmpty': 'Write an answer first',
800
+ 'needsUser.answerTooLong': 'The answer must be at most {max} chars',
801
+ 'needsUser.pickOption': 'Click an option to fill the box, or write your own answer.',
730
802
  }
731
803
 
732
804
  function detectLang(locale) {
@@ -900,6 +972,51 @@ window.__ModuleLoader__.load({
900
972
  return sessionId.length > 8 ? sessionId.slice(-8) : sessionId
901
973
  }
902
974
 
975
+ // 会话 id 只认两种形态:`session-<id>`(宿主会话)与裸 UUID(宿主 `subagentId` 就是会话 UUID)。
976
+ // 任务 `assignee` 是自由文本,组长也可能写 `worker-42` / `main` 这类普通标签,那些不是会话。
977
+ const SESSION_ID_PATTERN = /^(?:session-[A-Za-z0-9_-]+|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/i
978
+ // 从自由文本里找会话 id token 用:不带锚点,但两侧边界不能是 `[A-Za-z0-9_-]`(见 extractSessionId)。
979
+ const SESSION_TOKEN_PATTERN = /session-[A-Za-z0-9_-]+|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi
980
+ const SESSION_TOKEN_EDGE = /[A-Za-z0-9_-]/
981
+
982
+ /** 整串就是会话 id(严格判定,不做提取)。 */
983
+ function looksLikeSessionId(value) {
984
+ return typeof value === 'string' && SESSION_ID_PATTERN.test(value.trim())
985
+ }
986
+
987
+ /**
988
+ * 从 `assignee` 这类自由文本里提取第一个会话 id(t-39 增量):
989
+ * 组长常把 id 写成 `5a6b…(worker)` / `… (worker)` / `…@worker` / `worker: …`,
990
+ * 整串严格匹配会漏掉 → 卡片回退组长会话。这里按 token 扫描,返回 id 本身(保留原始大小写)。
991
+ * 边界:token 前后不能紧邻 `[A-Za-z0-9_-]`,所以 `worker-42` / `main` / 中文标签 /
992
+ * `session-`(dash 后没有 id)/ 被别的词粘住的片段都不算会话,返回空串。
993
+ */
994
+ function extractSessionId(value) {
995
+ if (typeof value !== 'string') return ''
996
+ const text = value.trim()
997
+ if (text === '') return ''
998
+ if (looksLikeSessionId(text)) return text
999
+ SESSION_TOKEN_PATTERN.lastIndex = 0
1000
+ let match = SESSION_TOKEN_PATTERN.exec(text)
1001
+ while (match !== null) {
1002
+ const end = match.index + match[0].length
1003
+ const before = match.index > 0 ? text.charAt(match.index - 1) : ''
1004
+ const after = end < text.length ? text.charAt(end) : ''
1005
+ if (!SESSION_TOKEN_EDGE.test(before) && !SESSION_TOKEN_EDGE.test(after)) return match[0]
1006
+ match = SESSION_TOKEN_PATTERN.exec(text)
1007
+ }
1008
+ return ''
1009
+ }
1010
+
1011
+ /**
1012
+ * 任务真正的「执行对话」(worker 子会话):组长直聊派活时把 worker 会话 id 写进 `task.assignee`(§1.8),
1013
+ * 但 `assignee` 也可能是普通标签 —— 只有文本里能提取到会话 id 时才返回,否则返回空串(不当会话打开)。
1014
+ */
1015
+ function workerSessionOf(task) {
1016
+ if (!task || typeof task !== 'object') return ''
1017
+ return extractSessionId(task.assignee)
1018
+ }
1019
+
903
1020
  /* ── v0.2.0 组长条(主会话 / 工作区组长)纯展示函数 ───────── */
904
1021
 
905
1022
  // 「派发到」的四个合法值:v0.2.0 起默认 workspace-lead(缺省 / 未知一律回退它,不要回退 new)。
@@ -1481,6 +1598,36 @@ window.__ModuleLoader__.load({
1481
1598
  return groups
1482
1599
  }
1483
1600
 
1601
+ /**
1602
+ * v0.2.2(§1.9):派生「待你处理」任务列表——`needsUser === true`、排除已归档,
1603
+ * 按 `askedAt` 升序(等得最久的排最前;缺 / 坏 `askedAt` 的排最后,再按 id)。
1604
+ */
1605
+ function needsUserTasks(tasks) {
1606
+ return (Array.isArray(tasks) ? tasks : [])
1607
+ .filter((task) => task && task.needsUser === true && task.status !== 'archived')
1608
+ .slice()
1609
+ .sort((a, b) => {
1610
+ const at = Date.parse(typeof a.askedAt === 'string' ? a.askedAt : '')
1611
+ const bt = Date.parse(typeof b.askedAt === 'string' ? b.askedAt : '')
1612
+ const aOk = Number.isFinite(at)
1613
+ const bOk = Number.isFinite(bt)
1614
+ if (aOk && bOk && at !== bt) return at - bt
1615
+ if (aOk !== bOk) return aOk ? -1 : 1
1616
+ return String(a.id).localeCompare(String(b.id))
1617
+ })
1618
+ }
1619
+
1620
+ /**
1621
+ * v0.2.2:普通四列 / lane 用的任务——未归档的 flagged 任务只在「待你处理」区出现,不重复;
1622
+ * 已归档的 flagged 任务不在「待你处理」派生列表里(needsUserTasks 排除 archived),
1623
+ * 所以照常留在「已归档」列,避免任务凭空消失。
1624
+ */
1625
+ function withoutNeedsUser(tasks) {
1626
+ return (Array.isArray(tasks) ? tasks : []).filter(
1627
+ (task) => !task || task.needsUser !== true || task.status === 'archived',
1628
+ )
1629
+ }
1630
+
1484
1631
  function errorText(t, error) {
1485
1632
  if (!error || typeof error !== 'object') return t('error.internal')
1486
1633
  const code = error.code || 'internal'
@@ -1757,6 +1904,51 @@ window.__ModuleLoader__.load({
1757
1904
  }
1758
1905
  }
1759
1906
 
1907
+ /**
1908
+ * 「再点一次收起」的判定:右栏已展开、且当前活动 tab 就是本插件的看板页时,返回该 TabRecord
1909
+ * (用它的 id 调 hide),否则返回 null。
1910
+ *
1911
+ * 只看右栏公开 API(0.2.2-rc.1 的 `ISidebarRight`:`active()` / `isExpanded()` / `hide(tabId)`);
1912
+ * 任一 API 缺失或抛错都当作「没开」,让点击继续走 openBoard —— 收起是锦上添花,
1913
+ * 绝不能把打开这条主路径挡掉。`TabRecord` 的形状实测为 `{ id, kind, title, contentId }`,
1914
+ * 本插件注册的页类型 kind 就是 TAB_KIND(见 §5.0)。
1915
+ */
1916
+ function expandedBoardTab() {
1917
+ if (!sidebarRightService) return null
1918
+ if (typeof sidebarRightService.active !== 'function') return null
1919
+ if (typeof sidebarRightService.isExpanded !== 'function') return null
1920
+ try {
1921
+ if (sidebarRightService.isExpanded() !== true) return null
1922
+ } catch (error) {
1923
+ return null
1924
+ }
1925
+ try {
1926
+ const tab = sidebarRightService.active()
1927
+ if (tab && typeof tab === 'object' && tab.kind === TAB_KIND && typeof tab.id === 'string') return tab
1928
+ } catch (error) {
1929
+ /* 读不到活动 tab 就按「没开」处理 */
1930
+ }
1931
+ return null
1932
+ }
1933
+
1934
+ /**
1935
+ * header 图标:看板已展开且在眼前 → 收起(docked 折叠整列 / floating 关闭浮层,tab 本身保留,
1936
+ * 下次点开还在);其它情况(没开 / 已收起 / 活动 tab 是别的)→ 照常 openTab 打开并聚焦。
1937
+ */
1938
+ function toggleBoard(retry = 0) {
1939
+ const tab = expandedBoardTab()
1940
+ if (tab && sidebarRightService && typeof sidebarRightService.hide === 'function') {
1941
+ try {
1942
+ sidebarRightService.hide(tab.id)
1943
+ return
1944
+ } catch (error) {
1945
+ // 收起失败不该变成「点了没反应」:下面照常打开。
1946
+ console.warn('[dsh-dispatch-board] 收起右侧看板失败:' + (error && error.message ? error.message : error))
1947
+ }
1948
+ }
1949
+ openBoard(retry)
1950
+ }
1951
+
1760
1952
  /* ── 图标 ───────────────────────────────────────────────── */
1761
1953
 
1762
1954
  /** 看板 glyph:会话 header 按钮、右栏 tab chip、引导页入口共用。 */
@@ -1788,6 +1980,8 @@ window.__ModuleLoader__.load({
1788
1980
  // 顺手记下当前对话 id(幂等赋值):根作用域的平台看板靠它绑定主会话,拿不到就禁用按钮。
1789
1981
  if (sessionId !== '') lastConversationSessionId = sessionId
1790
1982
  const [pending, setPending] = useState(-1)
1983
+ // v0.2.2(§1.9):待你处理数量单独一个红色角标(与 todo 角标并存、互不干扰)。
1984
+ const [needsCount, setNeedsCount] = useState(-1)
1791
1985
  // 按钮打开的是「本工作区看板」,角标也按本工作区数;拿不到工作区(冷会话)时退回全平台数。
1792
1986
  const cwdRef = useRef('')
1793
1987
 
@@ -1812,14 +2006,24 @@ window.__ModuleLoader__.load({
1812
2006
  callRpc('snapshot', {}).then((res) => {
1813
2007
  if (!alive) return
1814
2008
  if (!res.ok || !res.value || !Array.isArray(res.value.tasks)) return
1815
- const workspace = cwdRef.current
2009
+ // 与右栏看板(banner / 四列)用同一个过滤:cwd 属于本工作区,或任务创建于本对话。
2010
+ // 只按 cwd 过滤会让「banner 有、header 角标为 0」——旧任务 / 工具建的任务可能没有 cwd。
2011
+ // sessionId 缺失(理论上宿主不会这样渲染)时退回全量,与旧行为一致。
2012
+ const visible =
2013
+ sessionId === '' ? res.value.tasks : tasksForWorkspace(res.value.tasks, cwdRef.current, sessionId)
1816
2014
  let count = 0
1817
- for (const task of res.value.tasks) {
2015
+ let needs = 0
2016
+ for (const task of visible) {
2017
+ // flagged 任务算「待你处理」,不算 todo 待办(两枚角标不重复计数)。
2018
+ if (task.needsUser === true && task.status !== 'archived') {
2019
+ needs += 1
2020
+ continue
2021
+ }
1818
2022
  if (task.status !== 'todo') continue
1819
- if (workspace !== '' && !samePath(task.cwd, workspace)) continue
1820
2023
  count += 1
1821
2024
  }
1822
2025
  setPending(count)
2026
+ setNeedsCount(needs)
1823
2027
  })
1824
2028
  }
1825
2029
  read()
@@ -1831,7 +2035,11 @@ window.__ModuleLoader__.load({
1831
2035
  }, [])
1832
2036
 
1833
2037
  const badge = pending > 0 ? (pending > 99 ? '99+' : String(pending)) : null
1834
- const tip = t('panel.label') + (pending > 0 ? ' · ' + t('badge.label', { n: pending }) : '')
2038
+ const needsBadge = needsCount > 0 ? (needsCount > 99 ? '99+' : String(needsCount)) : null
2039
+ const tip =
2040
+ t('panel.label') +
2041
+ (pending > 0 ? ' · ' + t('badge.label', { n: pending }) : '') +
2042
+ (needsCount > 0 ? ' · ' + t('needsUser.badge', { n: needsCount }) : '')
1835
2043
 
1836
2044
  return h(
1837
2045
  'button',
@@ -1840,10 +2048,15 @@ window.__ModuleLoader__.load({
1840
2048
  className: 'tb-headbtn',
1841
2049
  title: tip,
1842
2050
  'aria-label': t('action.openBoard'),
1843
- onClick: openBoard,
2051
+ // 不用 openBoard 直连:onClick 会把事件对象当第一个参数传进去(retry 失效),
2052
+ // 而且这里要走「已展开就收起」的 toggle。
2053
+ onClick: () => toggleBoard(),
1844
2054
  },
1845
2055
  h(BoardGlyph, { size: 16 }),
1846
2056
  badge === null ? null : h('span', { className: 'tb-badge', 'aria-hidden': 'true' }, badge),
2057
+ needsBadge === null
2058
+ ? null
2059
+ : h('span', { className: 'tb-badge tb-badge-needs', 'aria-hidden': 'true' }, needsBadge),
1847
2060
  )
1848
2061
  }
1849
2062
 
@@ -1871,22 +2084,40 @@ window.__ModuleLoader__.load({
1871
2084
  // 组件身份因此保持不变,2s 轮询刷新不会卸载重建它们(否则详情浮层会闪、滚动位置/编辑态会丢)。
1872
2085
 
1873
2086
  /**
1874
- * 任务关联的会话:优先「执行对话」,其次「发起对话」;
1875
2087
  * 老版本 Host 派发的进行中任务没记 dispatchedSessionId,用 snapshot.poll 的最近派发兜底
1876
- * (仅当同时只有一条 doing 任务时,避免张冠李戴)。
2088
+ * (仅当同时只有一条 doing 任务时,避免张冠李戴)。兜底会话是「派发到哪个会话」,即组长会话。
1877
2089
  */
1878
- function sessionOf(task) {
2090
+ function pollFallbackSessionOf(task) {
1879
2091
  if (!task) return ''
1880
- if (task.dispatchedSessionId) return task.dispatchedSessionId
1881
- if (task.sessionId) return task.sessionId
1882
2092
  const fallback = typeof bind.fallbackDispatchSessionId === 'string' ? bind.fallbackDispatchSessionId : ''
1883
- if (task.status === 'doing' && fallback !== '') {
1884
- const lastDispatchTaskId = typeof bind.lastDispatchTaskId === 'string' ? bind.lastDispatchTaskId : ''
1885
- if (lastDispatchTaskId === '' || lastDispatchTaskId === task.id) return fallback
1886
- }
2093
+ if (fallback === '') return ''
2094
+ if (task.status !== 'doing') return ''
2095
+ const lastDispatchTaskId = typeof bind.lastDispatchTaskId === 'string' ? bind.lastDispatchTaskId : ''
2096
+ if (lastDispatchTaskId === '' || lastDispatchTaskId === task.id) return fallback
1887
2097
  return ''
1888
2098
  }
1889
2099
 
2100
+ /** 组长会话:`dispatchedSessionId`,其次老 Host 的 poll 兜底。 */
2101
+ function leadSessionOf(task) {
2102
+ if (!task) return ''
2103
+ const dispatched = typeof task.dispatchedSessionId === 'string' ? task.dispatchedSessionId : ''
2104
+ return dispatched !== '' ? dispatched : pollFallbackSessionOf(task)
2105
+ }
2106
+
2107
+ /**
2108
+ * 任务关联的会话(卡片「对话」按钮的跳转目标),优先级:
2109
+ * worker 子会话(真正执行任务的对话)→ 组长会话(dispatchedSessionId)→ 发起对话(sessionId)
2110
+ * → 老 Host 的 poll 兜底(doing)。没有 worker 时组长会话不再冒充「执行对话」,但仍是卡片的首选跳转。
2111
+ */
2112
+ function sessionOf(task) {
2113
+ if (!task) return ''
2114
+ const worker = workerSessionOf(task)
2115
+ if (worker !== '') return worker
2116
+ if (typeof task.dispatchedSessionId === 'string' && task.dispatchedSessionId !== '') return task.dispatchedSessionId
2117
+ if (typeof task.sessionId === 'string' && task.sessionId !== '') return task.sessionId
2118
+ return pollFallbackSessionOf(task)
2119
+ }
2120
+
1890
2121
  /* ── 子组件 ───────────────────────────────────────────── */
1891
2122
 
1892
2123
  function Banner(props) {
@@ -1955,6 +2186,113 @@ window.__ModuleLoader__.load({
1955
2186
  )
1956
2187
  }
1957
2188
 
2189
+ /**
2190
+ * 右栏看板顶部的「待你处理」条(v0.2.2,§1.9):只读 bind.needsUserTasks,
2191
+ * 空列表返回 null(整块不渲染,不是空态盒子)。点条目打开详情浮层的回答区。
2192
+ */
2193
+ function NeedsBanner() {
2194
+ const t = bind.t
2195
+ const list = Array.isArray(bind.needsUserTasks) ? bind.needsUserTasks : []
2196
+ if (list.length === 0) return null
2197
+ const actions = bind.actions
2198
+ return h(
2199
+ 'section',
2200
+ { className: 'tb-needs', role: 'region', 'aria-label': t('column.needsUser') },
2201
+ h(
2202
+ 'header',
2203
+ { className: 'tb-needs-head' },
2204
+ h('span', { className: 'tb-needs-dot', 'aria-hidden': 'true' }),
2205
+ h('span', { className: 'tb-needs-name' }, t('column.needsUser')),
2206
+ h('span', { className: 'tb-needs-count' }, String(list.length)),
2207
+ ),
2208
+ h(
2209
+ 'div',
2210
+ { className: 'tb-needs-list' },
2211
+ list.map((task) =>
2212
+ h(
2213
+ 'button',
2214
+ {
2215
+ key: task.id,
2216
+ type: 'button',
2217
+ className: 'tb-needs-item',
2218
+ title: (task.title || '') + '\n' + (task.question || ''),
2219
+ onClick: () => actions.openDetail(task),
2220
+ },
2221
+ h('span', { className: 'tb-needs-title' }, task.title || ''),
2222
+ h('span', { className: 'tb-needs-q' }, task.question || ''),
2223
+ ),
2224
+ ),
2225
+ ),
2226
+ )
2227
+ }
2228
+
2229
+ /**
2230
+ * 平台看板的第五列「待你处理」(v0.2.2,§1.9):放在「待开始」之前,仅非空时由调用方渲染。
2231
+ * 卡片显示标题 + 问题一行 + 「处理」按钮(需要用户阅读,是纯标题卡的例外);
2232
+ * 点标题 / 「处理」都打开详情浮层的回答区。
2233
+ */
2234
+ function NeedsColumn(props) {
2235
+ const t = bind.t
2236
+ const list = props && Array.isArray(props.tasks) ? props.tasks : []
2237
+ const actions = bind.actions
2238
+ return h(
2239
+ 'section',
2240
+ {
2241
+ className: 'tb-col tb-needs-col',
2242
+ 'data-status': 'needsUser',
2243
+ 'aria-label': t('column.needsUser'),
2244
+ },
2245
+ h(
2246
+ 'header',
2247
+ { className: 'tb-colhead', style: { '--tb-accent': STATUS_ACCENT.needsUser } },
2248
+ h('span', { className: 'tb-coldot', 'aria-hidden': 'true' }),
2249
+ h('span', { className: 'tb-colname' }, t('column.needsUser')),
2250
+ h('span', { className: 'tb-colcount' }, String(list.length)),
2251
+ ),
2252
+ h(
2253
+ 'div',
2254
+ { className: 'tb-cards' },
2255
+ list.map((task) =>
2256
+ h(
2257
+ 'article',
2258
+ {
2259
+ key: task.id,
2260
+ className: 'tb-card tb-card-fixed tb-needs-card',
2261
+ style: { '--tb-accent': STATUS_ACCENT.needsUser },
2262
+ },
2263
+ h(
2264
+ 'div',
2265
+ {
2266
+ className: 'tb-card-title tb-card-titlebtn',
2267
+ role: 'button',
2268
+ tabIndex: 0,
2269
+ title: task.title,
2270
+ onClick: () => actions.openDetail(task),
2271
+ onKeyDown: (event) => {
2272
+ if (event.key === 'Enter' || event.key === ' ') {
2273
+ event.preventDefault()
2274
+ actions.openDetail(task)
2275
+ }
2276
+ },
2277
+ },
2278
+ task.title,
2279
+ ),
2280
+ h('div', { className: 'tb-needs-card-q', title: task.question || '' }, task.question || ''),
2281
+ h(
2282
+ 'div',
2283
+ { className: 'tb-card-actions' },
2284
+ h(
2285
+ 'button',
2286
+ { type: 'button', className: 'tb-btn tb-btn-sm tb-btn-primary', onClick: () => actions.openDetail(task) },
2287
+ t('needsUser.open'),
2288
+ ),
2289
+ ),
2290
+ ),
2291
+ ),
2292
+ ),
2293
+ )
2294
+ }
2295
+
1958
2296
  function Card(props) {
1959
2297
  const t = bind.t
1960
2298
  const busy = bind.busy
@@ -2030,12 +2368,14 @@ window.__ModuleLoader__.load({
2030
2368
 
2031
2369
  // 卡片只留标题 + 操作按钮:note / result / lastError / id / 工作区 / 时间 /
2032
2370
  // 执行者 / 组长这些背景信息都在详情浮层里看(点标题或「详情」)。
2033
- // 少这一整段后卡片能视觉等高(.tb-card-fixed 的 min-height + 操作行 margin-top:auto)。
2371
+ // 少这一整段后卡片高度由内容决定(.tb-card-fixed 的标题固定 2 行高度 +
2372
+ // 标题/按钮之间只留 gap,不再用整卡 min-height + 操作行 margin-top:auto 撑空行)。
2034
2373
 
2035
2374
  cardActions.unshift(['detail', () => actions.openDetail(task), false])
2375
+ // 卡片「对话」优先 worker 子会话(真正干活的对话),其次组长 / 发起对话;title 用实际目标 id 便于辨认。
2036
2376
  const cardSessionId = sessionOf(task)
2037
2377
  if (cardSessionId !== '') {
2038
- cardActions.push(['openChat', () => actions.openSession({ dispatchedSessionId: cardSessionId, sessionId: task.sessionId }), false])
2378
+ cardActions.push(['openChat', () => actions.openSession(cardSessionId), false, cardSessionId])
2039
2379
  }
2040
2380
 
2041
2381
  return h(
@@ -2072,6 +2412,8 @@ window.__ModuleLoader__.load({
2072
2412
  'tb-btn tb-btn-sm' +
2073
2413
  (entry[2] ? ' tb-btn-primary' : '') +
2074
2414
  (entry[0] === 'delete' ? ' tb-btn-danger tb-btn-ghost' : ''),
2415
+ // 可选第 4 项:按钮 title(「对话」按钮用实际跳转的会话 id)。
2416
+ title: entry[3],
2075
2417
  disabled: busy === busyKey || busy === 'dispatch:' + task.id || busy === 'delete:' + task.id,
2076
2418
  onClick: entry[1],
2077
2419
  },
@@ -2093,6 +2435,11 @@ window.__ModuleLoader__.load({
2093
2435
  attachmentLoadingText: t('detail.imageLoading'),
2094
2436
  attachmentFailedText: t('detail.imageFailed'),
2095
2437
  }
2438
+ // v0.2.2「待你处理」:回答区读看板组件的草稿 / 错误 / 忙态(浮层不持有 state)。
2439
+ const needsOptions = task.needsUser === true && Array.isArray(task.questionOptions) ? task.questionOptions : []
2440
+ const answerDraft = typeof bind.answerDraft === 'string' ? bind.answerDraft : ''
2441
+ const answerError = typeof bind.answerError === 'string' ? bind.answerError : ''
2442
+ const answerBusyKey = 'answer:' + task.id
2096
2443
  const metaRows = [
2097
2444
  [t('detail.workspace'), task.cwd || '—'],
2098
2445
  [t('detail.lead'), taskLeadLabel(task) || t('detail.noLead')],
@@ -2108,6 +2455,21 @@ window.__ModuleLoader__.load({
2108
2455
  [t('detail.archived'), fmtShortWhen(task.archivedAt), fmtWhen(task.archivedAt)],
2109
2456
  ]
2110
2457
  const resultEmpty = task.status === 'done' && !task.result
2458
+ // 「关联对话」:发起(sessionId)/ 执行(worker assignee)/ 组长(dispatchedSessionId / poll 兜底),
2459
+ // 各自可点;同一个会话只显示一次(worker 可能等于发起会话,组长会话也可能等于发起会话)。
2460
+ const creatorSession = typeof task.sessionId === 'string' ? task.sessionId : ''
2461
+ const workerSession = workerSessionOf(task)
2462
+ const leadSession = leadSessionOf(task)
2463
+ const detailSessions = []
2464
+ if (creatorSession !== '') {
2465
+ detailSessions.push({ key: 'creator', label: t('detail.creatorSession'), sessionId: creatorSession })
2466
+ }
2467
+ if (workerSession !== '' && workerSession !== creatorSession) {
2468
+ detailSessions.push({ key: 'worker', label: t('detail.runSession'), sessionId: workerSession })
2469
+ }
2470
+ if (leadSession !== '' && leadSession !== workerSession && leadSession !== creatorSession) {
2471
+ detailSessions.push({ key: 'lead', label: t('detail.leadSession'), sessionId: leadSession })
2472
+ }
2111
2473
  const quick =
2112
2474
  task.status === 'todo'
2113
2475
  ? ['doing', t('card.start')]
@@ -2157,6 +2519,68 @@ window.__ModuleLoader__.load({
2157
2519
  h(
2158
2520
  'div',
2159
2521
  { className: 'tb-detail-body' },
2522
+ // v0.2.2「待你处理」:问题 / 选项 / 自由输入 / 回复并继续 / 最近回答(§1.9)。
2523
+ // 草稿与错误状态放在看板组件里(经 bind 传入),浮层本身不调 hooks。
2524
+ task.needsUser
2525
+ ? h(
2526
+ 'section',
2527
+ { className: 'tb-detail-section tb-detail-needs' },
2528
+ h('h3', { className: 'tb-detail-sub' }, t('needsUser.title')),
2529
+ h('p', { className: 'tb-needs-question', 'aria-label': t('needsUser.question') }, task.question || ''),
2530
+ needsOptions.length > 0
2531
+ ? h(
2532
+ 'div',
2533
+ { className: 'tb-needs-options' },
2534
+ needsOptions.map((option) =>
2535
+ h(
2536
+ 'button',
2537
+ {
2538
+ key: option,
2539
+ type: 'button',
2540
+ className: 'tb-btn tb-btn-sm',
2541
+ disabled: bind.busy === answerBusyKey,
2542
+ onClick: () => bind.actions.setAnswerDraft(option),
2543
+ },
2544
+ option,
2545
+ ),
2546
+ ),
2547
+ )
2548
+ : null,
2549
+ h('textarea', {
2550
+ className: 'tb-textarea tb-answer',
2551
+ placeholder: t('needsUser.answerPlaceholder', { max: 1000 }),
2552
+ 'aria-label': t('needsUser.answerPlaceholder', { max: 1000 }),
2553
+ value: answerDraft,
2554
+ onChange: (event) => bind.actions.setAnswerDraft(event.target.value),
2555
+ }),
2556
+ answerError ? h('p', { className: 'tb-needs-error', role: 'alert' }, answerError) : null,
2557
+ h('p', { className: 'tb-needs-hint' }, t('needsUser.pickOption')),
2558
+ h(
2559
+ 'div',
2560
+ { className: 'tb-detail-needs-actions' },
2561
+ h(
2562
+ 'button',
2563
+ {
2564
+ type: 'button',
2565
+ className: 'tb-btn tb-btn-sm tb-btn-primary',
2566
+ disabled: bind.busy === answerBusyKey || answerDraft.trim() === '',
2567
+ onClick: () => bind.actions.submitAnswer(task.id),
2568
+ },
2569
+ t('needsUser.submit'),
2570
+ ),
2571
+ ),
2572
+ )
2573
+ : null,
2574
+ // v0.2.2:回答留档不依赖当前是否 flagged——回答成功后 needsUser 已清,
2575
+ // 详情仍要能看到「最近回答」(组长 / 用户回看任务时的重要上下文)。
2576
+ task.lastAnswer
2577
+ ? h(
2578
+ 'section',
2579
+ { className: 'tb-detail-section tb-detail-answer' },
2580
+ h('h3', { className: 'tb-detail-sub' }, t('needsUser.lastAnswer')),
2581
+ h('p', { className: 'tb-detail-lastanswer' }, task.lastAnswer),
2582
+ )
2583
+ : null,
2160
2584
  h(
2161
2585
  'section',
2162
2586
  { className: 'tb-detail-section' },
@@ -2207,33 +2631,21 @@ window.__ModuleLoader__.load({
2207
2631
  h(
2208
2632
  'div',
2209
2633
  { className: 'tb-detail-sessions' },
2210
- task.sessionId
2211
- ? h(
2212
- 'button',
2213
- {
2214
- type: 'button',
2215
- className: 'tb-btn tb-btn-sm',
2216
- title: task.sessionId,
2217
- onClick: () => props.openSession(task.sessionId),
2218
- },
2219
- t('detail.creatorSession') + ' · ' + shortSession(task.sessionId),
2220
- )
2221
- : null,
2222
- sessionOf(task) !== '' && sessionOf(task) !== task.sessionId
2223
- ? h(
2224
- 'button',
2225
- {
2226
- type: 'button',
2227
- className: 'tb-btn tb-btn-sm',
2228
- title: sessionOf(task),
2229
- onClick: () => props.openSession(sessionOf(task)),
2230
- },
2231
- t('detail.runSession') + ' · ' + shortSession(sessionOf(task)),
2232
- )
2233
- : null,
2234
- sessionOf(task) === ''
2235
- ? h('span', { className: 'tb-detail-muted' }, t('detail.noSession'))
2236
- : null,
2634
+ detailSessions.length === 0
2635
+ ? h('span', { className: 'tb-detail-muted' }, t('detail.noSession'))
2636
+ : detailSessions.map((entry) =>
2637
+ h(
2638
+ 'button',
2639
+ {
2640
+ key: entry.key,
2641
+ type: 'button',
2642
+ className: 'tb-btn tb-btn-sm',
2643
+ title: entry.sessionId,
2644
+ onClick: () => props.openSession(entry.sessionId),
2645
+ },
2646
+ entry.label + ' · ' + shortSession(entry.sessionId),
2647
+ ),
2648
+ ),
2237
2649
  ),
2238
2650
  ),
2239
2651
  ),
@@ -2433,7 +2845,7 @@ window.__ModuleLoader__.load({
2433
2845
  return h('div', { className: 'tb-leads', role: 'group', 'aria-label': t('lead.barLabel') }, cells)
2434
2846
  }
2435
2847
 
2436
- return { Banner, Col, Detail, LeadBar }
2848
+ return { Banner, Col, Detail, LeadBar, NeedsBanner, NeedsColumn }
2437
2849
  }
2438
2850
 
2439
2851
  /* ── 看板页 ─────────────────────────────────────────────── */
@@ -2464,6 +2876,9 @@ window.__ModuleLoader__.load({
2464
2876
  const [busy, setBusy] = useState('')
2465
2877
  const [confirmDeleteId, setConfirmDeleteId] = useState(null)
2466
2878
  const [detailId, setDetailId] = useState(null)
2879
+ // v0.2.2「待你处理」:回答草稿 / 行内错误(详情浮层只读,不持有 state)。
2880
+ const [answerDraft, setAnswerDraft] = useState('')
2881
+ const [answerError, setAnswerError] = useState('')
2467
2882
  // createBoardPieces 的稳定 bind / 组件缓存(避免轮询刷新时组件重建导致浮层闪烁)
2468
2883
  const boardBindRef = useRef(null)
2469
2884
  const boardPiecesRef = useRef(null)
@@ -2566,13 +2981,18 @@ window.__ModuleLoader__.load({
2566
2981
  // 右栏 = 本工作区看板:只显示 cwd 与当前工作区相同(归一化比较)的任务;
2567
2982
  // 工作区未知(历史会话 / 缺 cwd)时给说明条并显示空看板。
2568
2983
  const workspaceTitle = cwdForHint ? workspaceTitleOf(workspaces, cwdForHint) : ''
2569
- const tasks = tasksForWorkspace(allTasks, cwdForHint, sessionId)
2984
+ // v0.2.2(§1.9):flagged 任务只在顶部「待你处理」条显示,不进普通四列 / lane。
2985
+ // 条与四列都用本工作区可见任务(与看板范围一致)。
2986
+ const workspaceTasks = tasksForWorkspace(allTasks, cwdForHint, sessionId)
2987
+ const needsUser = needsUserTasks(workspaceTasks)
2988
+ const tasks = withoutNeedsUser(workspaceTasks)
2989
+ const plainTasks = withoutNeedsUser(allTasks)
2570
2990
  // 有些旧任务/别的会话建的任务没有 cwd,本面板按设计不显示;给个去处,避免「任务凭空消失」。
2571
2991
  const detailTask = detailId ? allTasks.find((task) => task && task.id === detailId) || null : null
2572
- const doingAll = allTasks.filter((task) => task && task.status === 'doing')
2992
+ const doingAll = plainTasks.filter((task) => task && task.status === 'doing')
2573
2993
  const fallbackDispatchSessionId =
2574
2994
  poll && poll.lastDispatchSessionId && (poll.lastDispatchTaskId || doingAll.length === 1) ? poll.lastDispatchSessionId : ''
2575
- const unboundElsewhere = allTasks.filter(
2995
+ const unboundElsewhere = plainTasks.filter(
2576
2996
  (task) => task && !task.cwd && task.status !== 'archived' && task.sessionId !== sessionId,
2577
2997
  ).length
2578
2998
  const groups = groupTasks(tasks)
@@ -2659,6 +3079,37 @@ window.__ModuleLoader__.load({
2659
3079
  })
2660
3080
  }
2661
3081
 
3082
+ /**
3083
+ * v0.2.2(§1.9):提交回答。不用 run():错误要显示在详情浮层的回答区(而不是顶部条),
3084
+ * 失败时不关闭浮层、不丢输入;成功后关闭浮层、清草稿并刷新看板。
3085
+ */
3086
+ function submitAnswer(taskId) {
3087
+ const answer = String(answerDraft || '').trim()
3088
+ if (answer === '') {
3089
+ setAnswerError(t('needsUser.answerEmpty'))
3090
+ return
3091
+ }
3092
+ if (answer.length > 1000) {
3093
+ setAnswerError(t('needsUser.answerTooLong', { max: 1000 }))
3094
+ return
3095
+ }
3096
+ setAnswerError('')
3097
+ setBusy('answer:' + taskId)
3098
+ callRpc('answer-task', { id: taskId, answer }).then((res) => {
3099
+ if (!aliveRef.current) return
3100
+ setBusy('')
3101
+ if (!res.ok) {
3102
+ setAnswerError(t('needsUser.answerFailed', { message: errorText(t, res.error) }))
3103
+ return
3104
+ }
3105
+ setAnswerDraft('')
3106
+ setAnswerError('')
3107
+ setDetailId(null)
3108
+ setNotice({ tone: 'ok', text: t('needsUser.answerOk') })
3109
+ refresh()
3110
+ })
3111
+ }
3112
+
2662
3113
  function setConfig(patch) {
2663
3114
  run('config', () => callRpc('set-config', patch))
2664
3115
  }
@@ -2735,13 +3186,26 @@ window.__ModuleLoader__.load({
2735
3186
  isConfirmingDelete: (id) => confirmDeleteId === id,
2736
3187
  openDetail: (task) => {
2737
3188
  if (task) loadTaskAttachments(task, attachmentSourcesRef, setAttachmentSources)
3189
+ // v0.2.2:换一条任务就清掉上一条的回答草稿 / 错误,避免答案串台。
3190
+ setAnswerDraft('')
3191
+ setAnswerError('')
2738
3192
  setDetailId(task.id)
2739
3193
  },
2740
- openSession: (task) => openSessionById(task && (task.dispatchedSessionId || task.sessionId)),
3194
+ // 「对话」按钮传目标会话 id;仍兼容传任务对象的旧调用(取 dispatched → creator)。
3195
+ openSession: (target) => {
3196
+ if (typeof target === 'string') {
3197
+ openSessionById(target)
3198
+ return
3199
+ }
3200
+ openSessionById(target && (target.dispatchedSessionId || target.sessionId))
3201
+ },
2741
3202
  startEdit,
2742
3203
  saveEdit,
2743
3204
  setEditing,
2744
3205
  archiveDone,
3206
+ // v0.2.2「待你处理」:回答草稿由看板持有,浮层通过 bind.actions 读写。
3207
+ setAnswerDraft,
3208
+ submitAnswer,
2745
3209
  }
2746
3210
  if (boardBindRef.current === null) {
2747
3211
  boardBindRef.current = {
@@ -2769,11 +3233,17 @@ window.__ModuleLoader__.load({
2769
3233
  boardBindRef.current.leadRows = leadRows
2770
3234
  boardBindRef.current.currentSessionId = sessionId
2771
3235
  boardBindRef.current.leadActions = leadActions
3236
+ // v0.2.2「待你处理」:条 / 第五列的任务列表与回答草稿(每次渲染都刷新)。
3237
+ boardBindRef.current.needsUserTasks = needsUser
3238
+ boardBindRef.current.answerDraft = answerDraft
3239
+ boardBindRef.current.answerError = answerError
2772
3240
  if (boardPiecesRef.current === null) boardPiecesRef.current = createBoardPieces(boardBindRef.current)
2773
3241
  const Banner = boardPiecesRef.current.Banner
2774
3242
  const Col = boardPiecesRef.current.Col
2775
3243
  const Detail = boardPiecesRef.current.Detail
2776
3244
  const LeadBar = boardPiecesRef.current.LeadBar
3245
+ const NeedsBanner = boardPiecesRef.current.NeedsBanner
3246
+ const NeedsColumn = boardPiecesRef.current.NeedsColumn
2777
3247
 
2778
3248
  /* ── 顶部状态文案 ─────────────────────────────────────── */
2779
3249
 
@@ -2989,6 +3459,9 @@ window.__ModuleLoader__.load({
2989
3459
  ),
2990
3460
  ),
2991
3461
 
3462
+ // v0.2.2(§1.9):顶部「待你处理」条(仅非空时由组件自己返回 null)。
3463
+ h(NeedsBanner, { key: 'needs' }),
3464
+
2992
3465
  wide
2993
3466
  ? h(
2994
3467
  'div',
@@ -3013,7 +3486,11 @@ window.__ModuleLoader__.load({
3013
3486
  detailTask
3014
3487
  ? h(Detail, {
3015
3488
  task: detailTask,
3016
- onClose: () => setDetailId(null),
3489
+ onClose: () => {
3490
+ setDetailId(null)
3491
+ setAnswerDraft('')
3492
+ setAnswerError('')
3493
+ },
3017
3494
  onStatus: (status) => {
3018
3495
  setDetailId(null)
3019
3496
  updateTask(detailTask.id, { status })
@@ -3030,6 +3507,8 @@ window.__ModuleLoader__.load({
3030
3507
  function PlatformPanelIcon(props) {
3031
3508
  const size = props && typeof props.size === 'number' && props.size > 0 ? props.size : 18
3032
3509
  const [openCount, setOpenCount] = useState(-1)
3510
+ // v0.2.2(§1.9):待你处理数量单独一个红色角标。
3511
+ const [needsCount, setNeedsCount] = useState(-1)
3033
3512
 
3034
3513
  useEffect(() => {
3035
3514
  let alive = true
@@ -3039,10 +3518,17 @@ window.__ModuleLoader__.load({
3039
3518
  if (!alive) return
3040
3519
  if (!res.ok || !res.value || !Array.isArray(res.value.tasks)) return
3041
3520
  let count = 0
3521
+ let needs = 0
3042
3522
  for (const task of res.value.tasks) {
3523
+ // flagged 任务算「待你处理」,不算未完成待办(两枚角标不重复计数)。
3524
+ if (task.needsUser === true && task.status !== 'archived') {
3525
+ needs += 1
3526
+ continue
3527
+ }
3043
3528
  if (task.status === 'todo' || task.status === 'doing') count += 1
3044
3529
  }
3045
3530
  setOpenCount(count)
3531
+ setNeedsCount(needs)
3046
3532
  })
3047
3533
  }
3048
3534
  read()
@@ -3054,12 +3540,19 @@ window.__ModuleLoader__.load({
3054
3540
  }, [])
3055
3541
 
3056
3542
  const badge = openCount > 0 ? (openCount > 99 ? '99+' : String(openCount)) : null
3057
- const tip = t('platform.label') + (openCount > 0 ? ' · ' + t('badge.open', { n: openCount }) : '')
3543
+ const needsBadge = needsCount > 0 ? (needsCount > 99 ? '99+' : String(needsCount)) : null
3544
+ const tip =
3545
+ t('platform.label') +
3546
+ (openCount > 0 ? ' · ' + t('badge.open', { n: openCount }) : '') +
3547
+ (needsCount > 0 ? ' · ' + t('needsUser.badge', { n: needsCount }) : '')
3058
3548
  return h(
3059
3549
  'span',
3060
3550
  { className: 'tb-icon', title: tip },
3061
3551
  h(BoardGlyph, { size }),
3062
3552
  badge === null ? null : h('span', { className: 'tb-badge', 'aria-hidden': 'true' }, badge),
3553
+ needsBadge === null
3554
+ ? null
3555
+ : h('span', { className: 'tb-badge tb-badge-needs', 'aria-hidden': 'true' }, needsBadge),
3063
3556
  )
3064
3557
  }
3065
3558
 
@@ -3071,6 +3564,9 @@ window.__ModuleLoader__.load({
3071
3564
  const [busy, setBusy] = useState('')
3072
3565
  const [confirmDeleteId, setConfirmDeleteId] = useState(null)
3073
3566
  const [detailId, setDetailId] = useState(null)
3567
+ // v0.2.2「待你处理」:回答草稿 / 行内错误(详情浮层只读,不持有 state)。
3568
+ const [answerDraft, setAnswerDraft] = useState('')
3569
+ const [answerError, setAnswerError] = useState('')
3074
3570
  // createBoardPieces 的稳定 bind / 组件缓存(避免轮询刷新时组件重建导致浮层闪烁)
3075
3571
  const boardBindRef = useRef(null)
3076
3572
  const boardPiecesRef = useRef(null)
@@ -3145,9 +3641,12 @@ window.__ModuleLoader__.load({
3145
3641
  })
3146
3642
  }
3147
3643
 
3148
- const visibleTasks = tasksForFilter(allTasks, filterPath)
3644
+ const visibleAll = tasksForFilter(allTasks, filterPath)
3645
+ // v0.2.2(§1.9):flagged 任务只进最左第五列,不重复出现在普通四列。
3646
+ const needsUser = needsUserTasks(visibleAll)
3647
+ const visibleTasks = withoutNeedsUser(visibleAll)
3149
3648
  const groups = groupTasks(visibleTasks)
3150
- const doingAll = allTasks.filter((task) => task && task.status === 'doing')
3649
+ const doingAll = withoutNeedsUser(allTasks).filter((task) => task && task.status === 'doing')
3151
3650
  const fallbackDispatchSessionId =
3152
3651
  poll && poll.lastDispatchSessionId && (poll.lastDispatchTaskId || doingAll.length === 1) ? poll.lastDispatchSessionId : ''
3153
3652
  const detailTask = detailId ? allTasks.find((task) => task && task.id === detailId) || null : null
@@ -3238,6 +3737,37 @@ window.__ModuleLoader__.load({
3238
3737
  })
3239
3738
  }
3240
3739
 
3740
+ /**
3741
+ * v0.2.2(§1.9):提交回答。不用 run():错误要显示在详情浮层的回答区(而不是顶部条),
3742
+ * 失败时不关闭浮层、不丢输入;成功后关闭浮层、清草稿并刷新看板。
3743
+ */
3744
+ function submitAnswer(taskId) {
3745
+ const answer = String(answerDraft || '').trim()
3746
+ if (answer === '') {
3747
+ setAnswerError(t('needsUser.answerEmpty'))
3748
+ return
3749
+ }
3750
+ if (answer.length > 1000) {
3751
+ setAnswerError(t('needsUser.answerTooLong', { max: 1000 }))
3752
+ return
3753
+ }
3754
+ setAnswerError('')
3755
+ setBusy('answer:' + taskId)
3756
+ callRpc('answer-task', { id: taskId, answer }).then((res) => {
3757
+ if (!aliveRef.current) return
3758
+ setBusy('')
3759
+ if (!res.ok) {
3760
+ setAnswerError(t('needsUser.answerFailed', { message: errorText(t, res.error) }))
3761
+ return
3762
+ }
3763
+ setAnswerDraft('')
3764
+ setAnswerError('')
3765
+ setDetailId(null)
3766
+ setNotice({ tone: 'ok', text: t('needsUser.answerOk') })
3767
+ refresh()
3768
+ })
3769
+ }
3770
+
3241
3771
  function setConfig(patch) {
3242
3772
  run('config', () => callRpc('set-config', patch))
3243
3773
  }
@@ -3310,13 +3840,26 @@ window.__ModuleLoader__.load({
3310
3840
  isConfirmingDelete: (id) => confirmDeleteId === id,
3311
3841
  openDetail: (task) => {
3312
3842
  if (task) loadTaskAttachments(task, attachmentSourcesRef, setAttachmentSources)
3843
+ // v0.2.2:换一条任务就清掉上一条的回答草稿 / 错误,避免答案串台。
3844
+ setAnswerDraft('')
3845
+ setAnswerError('')
3313
3846
  setDetailId(task.id)
3314
3847
  },
3315
- openSession: (task) => openSessionById(task && (task.dispatchedSessionId || task.sessionId)),
3848
+ // 「对话」按钮传目标会话 id;仍兼容传任务对象的旧调用(取 dispatched → creator)。
3849
+ openSession: (target) => {
3850
+ if (typeof target === 'string') {
3851
+ openSessionById(target)
3852
+ return
3853
+ }
3854
+ openSessionById(target && (target.dispatchedSessionId || target.sessionId))
3855
+ },
3316
3856
  startEdit,
3317
3857
  saveEdit,
3318
3858
  setEditing,
3319
3859
  archiveDone,
3860
+ // v0.2.2「待你处理」:回答草稿由看板持有,浮层通过 bind.actions 读写。
3861
+ setAnswerDraft,
3862
+ submitAnswer,
3320
3863
  }
3321
3864
  if (boardBindRef.current === null) {
3322
3865
  boardBindRef.current = {
@@ -3349,6 +3892,8 @@ window.__ModuleLoader__.load({
3349
3892
  const Col = boardPiecesRef.current.Col
3350
3893
  const Detail = boardPiecesRef.current.Detail
3351
3894
  const LeadBar = boardPiecesRef.current.LeadBar
3895
+ const NeedsBanner = boardPiecesRef.current.NeedsBanner
3896
+ const NeedsColumn = boardPiecesRef.current.NeedsColumn
3352
3897
 
3353
3898
  const intervalText = fmtInterval(config.pollIntervalMs)
3354
3899
  const busyNow = busy !== ''
@@ -3570,7 +4115,7 @@ window.__ModuleLoader__.load({
3570
4115
  workspaceOptions.map((option) => h('option', { key: option.path, value: option.path }, option.title)),
3571
4116
  ),
3572
4117
  ),
3573
- h('span', { className: 'tb-toolbar-count' }, t('platform.total', { n: visibleTasks.length })),
4118
+ h('span', { className: 'tb-toolbar-count' }, t('platform.total', { n: visibleAll.length })),
3574
4119
  ),
3575
4120
 
3576
4121
  allTasks.length === 0
@@ -3579,7 +4124,9 @@ window.__ModuleLoader__.load({
3579
4124
 
3580
4125
  h(
3581
4126
  'div',
3582
- { className: 'tb-board', 'data-layout': 'wide' },
4127
+ { className: 'tb-board', 'data-layout': 'wide', 'data-needs': needsUser.length > 0 ? 'true' : 'false' },
4128
+ // 第五列「待你处理」放最左(在「待开始」之前),仅非空时渲染。
4129
+ needsUser.length > 0 ? h(NeedsColumn, { key: 'needsUser', tasks: needsUser }) : null,
3583
4130
  STATUS_ORDER.map((status) => h(Col, { key: status, status, tasks: groups[status], compact: false })),
3584
4131
  ),
3585
4132
 
@@ -3595,7 +4142,11 @@ window.__ModuleLoader__.load({
3595
4142
  detailTask
3596
4143
  ? h(Detail, {
3597
4144
  task: detailTask,
3598
- onClose: () => setDetailId(null),
4145
+ onClose: () => {
4146
+ setDetailId(null)
4147
+ setAnswerDraft('')
4148
+ setAnswerError('')
4149
+ },
3599
4150
  onStatus: (status) => {
3600
4151
  setDetailId(null)
3601
4152
  updateTask(detailTask.id, { status })
@@ -3716,6 +4267,9 @@ window.__ModuleLoader__.load({
3716
4267
  fmtClock,
3717
4268
  fmtInterval,
3718
4269
  shortSession,
4270
+ // v0.2.0 任务关联对话:worker 会话判定(assignee 只在能提取到会话 id 时算会话)
4271
+ workerSessionOf,
4272
+ extractSessionId,
3719
4273
  groupTasks,
3720
4274
  statusAccent: STATUS_ACCENT,
3721
4275
  statusOrder: STATUS_ORDER,
@@ -3752,6 +4306,9 @@ window.__ModuleLoader__.load({
3752
4306
  taskLeadLabel,
3753
4307
  taskWorkspaceCwds,
3754
4308
  workspaceLeadRows,
4309
+ // v0.2.2「待你处理」(§1.9)派生列表
4310
+ needsUserTasks,
4311
+ withoutNeedsUser,
3755
4312
  }
3756
4313
 
3757
4314
  return module.exports