dsh-dispatch-board 0.1.3 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -6,13 +6,19 @@
6
6
  * sidebar.right.pane.tab / .title 提供正文与 chip,conversation.session.header.actions
7
7
  * 提供会话 header 入口按钮;只显示 cwd 与当前会话工作区相同的任务(窄栏 lane / 宽栏四列)。
8
8
  * 2. 左侧栏「平台任务看板」—— sidebar.panellist 入口图标(todo+doing 角标)+ main
9
- * (key: taskboard-platform) 页面;显示全部工作区的任务、每卡带工作区 tag,
9
+ * (key: taskboard-platform) 页面;显示全部工作区的任务(卡片只显示标题 + 操作按钮,
10
+ * 工作区 / 备注 / 结论等信息都在详情浮层),
10
11
  * 新建任务必须选工作区(add-task 传 cwd,不传 sessionId)。
11
12
  *
12
13
  * 数据通道:Host 在 webServer 注册的 /taskboard 前缀路由,经 Connection RPC 信封调用
13
14
  * (snapshot / session-info / add-task / update-task / delete-task / dispatch-now /
14
- * set-config / archive-done / install-preset)。snapshot 带 tasks / agents / workspaces。
15
- * 契约见 docs/architecture.md。
15
+ * set-config / archive-done / install-preset)。
16
+ * v0.2.0 新增:bind-main-session / clear-main-session / ensure-workspace-lead,
17
+ * 以及两块看板共用的「组长条」(snapshot.leads:主会话绑定状态 + 各工作区常驻组长)。
18
+ * v0.2.0 粘贴图片:新建备注 textarea 监听 paste → upload-attachment → note 只写短引用
19
+ * `![image](attachment://<uuid>)`;详情浮层按 id 调 attachment 渲染 <img>(不把 base64 写进 note)。
20
+ * snapshot 带 tasks / agents / workspaces / leads;leads 是运行时视图(组长启停 / 忙闲变化
21
+ * 不 bump revision),所以不能只比 revision 跳过重渲染。契约见 docs/architecture.md。
16
22
  *
17
23
  * 呈现层:手写 <style> 幂等注入,颜色 / 字体 / 圆角 / 焦点环全部来自官方 --dsw-* 主题变量,
18
24
  * 亮暗主题自动成立。唯一硬编码色是四列状态强调色(可视化用途)。
@@ -36,7 +42,7 @@ window.__ModuleLoader__.load({
36
42
  const BUNDLE_ID = 'dsh-dispatch-board'
37
43
  const RPC_CHANNEL = '/taskboard'
38
44
  const CSS_TAG_ID = BUNDLE_ID + '/client.css'
39
- const PLUGIN_VERSION = '0.1.0'
45
+ const PLUGIN_VERSION = '0.2.0' // 兜底值:正常走 snapshot.pluginVersion(宿主读 package.json)
40
46
  const POLL_VISIBLE_MS = 2000
41
47
  const POLL_HIDDEN_MS = 10000
42
48
  const ICON_POLL_MS = 6000
@@ -91,16 +97,24 @@ window.__ModuleLoader__.load({
91
97
  '.tb-composer-row{display:flex;align-items:center;gap:8px;min-width:0}',
92
98
  '.tb-composer-row .tb-input{flex:1 1 auto}',
93
99
  '.tb-composer-meta{display:flex;align-items:center;gap:10px;flex-wrap:wrap;font:var(--dsw-font-xxxs-11);color:var(--dsw-alias-label-tertiary)}',
100
+ '.tb-attach-strip{display:flex;flex-wrap:wrap;gap:8px}',
101
+ '.tb-attach-item{position:relative;width:64px;height:64px;border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm);overflow:hidden;background:var(--dsw-alias-bg-base)}',
102
+ '.tb-attach-thumb{display:block;width:100%;height:100%;object-fit:cover}',
103
+ '.tb-attach-remove{position:absolute;top:2px;right:2px;width:18px;height:18px;display:inline-flex;align-items:center;justify-content:center;padding:0;border:0;border-radius:50%;background:rgba(0,0,0,.58);color:#fff;font-size:12px;line-height:1;cursor:pointer}',
104
+ '.tb-attach-remove:hover{background:rgba(0,0,0,.75)}',
94
105
  '.tb-select{height:28px;max-width:290px;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-base);border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm);padding:0 6px;font:var(--dsw-font-xxxs-11);outline:none}',
95
106
  '.tb-select:focus-visible{border-color:var(--dsw-alias-state-business-primary)}',
96
107
  '.tb-linkbtn{display:inline-flex;align-items:center;gap:4px;border:0;background:transparent;color:var(--dsw-alias-link);cursor:pointer;padding:0;font:inherit}',
97
108
  '.tb-linkbtn:hover{text-decoration:underline}',
98
109
 
99
110
  // ── 看板 ───────────────────────────────────────────────────
100
- '.tb-board{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px;align-items:stretch;min-width:0;flex:1 1 auto;min-height:240px}',
111
+ '.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}',
101
112
  '.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%}',
102
113
  '.tb-col[data-status=archived]{opacity:.92}',
103
- '.tb-colhead{display:flex;align-items:center;gap:7px;padding:1px 1px 5px;border-bottom:1px solid var(--dsw-alias-border-l1)}',
114
+ '.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}',
115
+ // 列头高度固定:只有「已完成」列带「全部归档」按钮(24px 高),其它列只有文字(14px 行高)。
116
+ // 不固定时 flex 行高被按钮撑大 ~10px,导致「已完成」标题和整列卡片都比别的列低一截。
117
+ '.tb-page[data-narrow=true] .tb-colhead{height:29px}',
104
118
  '.tb-coldot{width:8px;height:8px;border-radius:50%;flex:0 0 auto;background:var(--tb-accent)}',
105
119
  '.tb-colname{font:var(--dsw-font-xxs-strong-12);font-weight:600;letter-spacing:.01em}',
106
120
  '.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}',
@@ -109,13 +123,10 @@ window.__ModuleLoader__.load({
109
123
  '.tb-empty{border:1px dashed var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm);padding:14px 10px;text-align:center;color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xxxs-11);line-height:1.6}',
110
124
 
111
125
  // ── 卡片 ───────────────────────────────────────────────────
112
- '.tb-card{display:flex;flex-direction:column;gap:6px;padding:9px 10px;background:var(--dsw-alias-bg-base);border:1px solid var(--dsw-alias-border-l1);border-left:3px solid var(--tb-accent);border-radius:var(--dsw-radius-sm);min-width:0}',
126
+ // 卡片正文只有标题 + 操作按钮:note / result / lastError / meta 全部收进详情浮层,
127
+ // 看板上只靠标题辨认任务(完整信息点标题看详情)。
128
+ '.tb-card{display:flex;flex-direction:column;gap:6px;padding:9px 10px;background:var(--dsw-alias-bg-base);border:1px solid var(--dsw-alias-border-l1);border-left:3px solid var(--tb-accent);border-radius:var(--dsw-radius-sm);min-width:0;box-sizing:border-box}',
113
129
  '.tb-card-title{font:var(--dsw-font-xxs-strong-12);font-weight:600;line-height:1.45;word-break:break-word}',
114
- '.tb-card-note{font:var(--dsw-font-xxxs-11);color:var(--dsw-alias-label-secondary);line-height:1.5;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;word-break:break-word}',
115
- '.tb-card-result{font:var(--dsw-font-xxxs-11);color:var(--dsw-alias-state-success-primary);line-height:1.5;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;word-break:break-word}',
116
- '.tb-card-error{font:var(--dsw-font-xxxs-11);color:var(--dsw-alias-state-error-primary);line-height:1.5;word-break:break-word}',
117
- '.tb-card-meta{display:flex;align-items:center;gap:6px;flex-wrap:wrap;font:var(--dsw-font-xxxs-11);color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums}',
118
- '.tb-card-tag{padding:1px 6px;border-radius:999px;background:color-mix(in srgb,var(--dsw-alias-label-primary) 7%,transparent);color:var(--dsw-alias-label-secondary);font:var(--dsw-font-xxxs-strong-11)}',
119
130
  '.tb-card-actions{display:flex;align-items:center;gap:4px;flex-wrap:wrap;padding-top:2px}',
120
131
  '.tb-edit{display:flex;flex-direction:column;gap:6px}',
121
132
  '.tb-edit-actions{display:flex;align-items:center;gap:6px;justify-content:flex-end}',
@@ -136,10 +147,24 @@ window.__ModuleLoader__.load({
136
147
  '.tb-headbtn:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}',
137
148
  '.tb-badge{position:absolute;top:-3px;right:-5px;min-width:14px;height:14px;padding:0 3px;display:inline-flex;align-items:center;justify-content:center;border-radius:999px;background:var(--dsw-alias-state-business-primary);color:var(--dsw-alias-label-primary-foreground);font:var(--dsw-font-xxxs-strong-11);font-size:9px;line-height:1;font-variant-numeric:tabular-nums}',
138
149
  '.tb-tabtitle{display:inline-flex;align-items:center;gap:5px;min-width:0}',
150
+ // 右栏 tab 的关闭按钮由宿主 dockkit chrome 渲染(本插件只提供正文与 chip):宿主 CSS 会在
151
+ // tab active / focus-within 时强制显示关闭按钮。这里只收紧带本插件标题(.tb-tabtitle)的 tab——
152
+ // 非悬停且非键盘聚焦时隐藏,悬停/聚焦时仍由宿主规则显示;:has 不被支持时整条规则被忽略,退回宿主行为。
153
+ '[data-dockkit-tab]:has(.tb-tabtitle):not(:hover):not(:focus-within) [data-dockkit-tab-close]{opacity:0!important;pointer-events:none!important}',
154
+ // 宿主在 hover / active 时用「标题右侧 30px 渐隐遮罩」给关闭按钮让位,而本插件 tab
155
+ // 只有内容宽(图标 + 任务看板 ≈ 71px)——遮罩从标题 41px 处开始,会把「板」吃掉。
156
+ // 比拉宽 tab 更省空间的做法:给 tab 右侧留出关闭按钮的 26px,并关掉这个遮罩;
157
+ // tab 只比原宽 +7px(≈100→107),标题完整、× 落在右侧留白里。
158
+ // 同时把宿主给 tab 的 min-width:80 放开(content-box 下它会让 tab 至少 80+padding 宽)。
159
+ '[data-dockkit-tab]:has(.tb-tabtitle){min-width:0;padding-right:24px}',
160
+ '[data-dockkit-tab]:has(.tb-tabtitle) [data-dockkit-tab-title]{mask-image:none!important}',
139
161
 
140
162
  // ── 右栏窄面板:lane 纵向堆叠 ──────────────────────────────
141
- '.tb-lanes{display:flex;flex-direction:column;gap:10px;min-height:0;flex:1 1 auto}',
163
+ '.tb-lanes{display:flex;flex-direction:column;gap:10px;min-height:0;flex:1 0 auto}',
142
164
  '.tb-page{position:relative}',
165
+ // 页面是唯一滚动容器:flex 子项默认 flex-shrink:1 会把看板压到 min-height,
166
+ // 内容从里面溢出、盖住页脚;这里统一禁止收缩,让 .tb-page 的 overflow-y:auto 生效。
167
+ '.tb-page > *{flex-shrink:0}',
143
168
  '.tb-card-titlebtn{cursor:pointer}',
144
169
  '.tb-card-titlebtn:hover{text-decoration:underline}',
145
170
  // ── 任务详情浮层 ─────────────────────────────────────────
@@ -195,6 +220,8 @@ window.__ModuleLoader__.load({
195
220
  '.tb-rich .tb-rich-table th{position:sticky;top:0;background:var(--dsw-alias-bg-base);padding:7px 10px;text-align:left;font-weight:600;border-bottom:1px solid var(--dsw-alias-border-l1);white-space:nowrap}',
196
221
  '.tb-rich .tb-rich-table td{padding:6px 10px;border-bottom:1px dashed var(--dsw-alias-border-l1);vertical-align:top;line-height:1.55}',
197
222
  '.tb-rich .tb-rich-table tr:last-child td{border-bottom:0}',
223
+ '.tb-rich .tb-rich-img{display:block;max-width:100%;height:auto;margin:6px 0;border:1px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-sm);background:var(--dsw-alias-bg-base)}',
224
+ '.tb-rich .tb-rich-attachment{display:inline-block;padding:1px 7px;border:1px dashed var(--dsw-alias-border-l2);border-radius:4px;color:var(--dsw-alias-label-secondary,#68707d);font:var(--dsw-font-xxxs-11)}',
198
225
  '.tb-detail-result{max-height:360px}',
199
226
  '.tb-detail-result-filled{border-left:3px solid var(--dsw-alias-state-success-primary,#16a34a)}',
200
227
  '.tb-detail-result[data-status=doing]{border-left:3px solid var(--dsw-alias-state-warn-primary,#d97706)}',
@@ -211,6 +238,8 @@ window.__ModuleLoader__.load({
211
238
  '.tb-page[data-narrow=true] .tb-board{grid-template-columns:minmax(0,1fr)}',
212
239
  '.tb-page[data-layout=medium] .tb-board{grid-template-columns:repeat(2,minmax(0,1fr))}',
213
240
  '.tb-page[data-narrow=true] .tb-col{min-height:0;height:auto;padding:8px 8px 9px}',
241
+ // 中/宽布局的空列占位在剩余高度里垂直居中(窄栏 lane 保持紧凑,不加高)。
242
+ '.tb-page[data-narrow=false] .tb-col > .tb-empty{flex:1 1 auto;display:flex;align-items:center;justify-content:center}',
214
243
  '.tb-page[data-narrow=true] .tb-empty{padding:8px}',
215
244
  '.tb-page[data-narrow=true] .tb-select{max-width:100%}',
216
245
  '.tb-page[data-narrow=true] .tb-foot{font-size:10px}',
@@ -224,6 +253,20 @@ window.__ModuleLoader__.load({
224
253
  '.tb-workspace-select{max-width:220px}',
225
254
  '.tb-platform-empty{margin-top:2px}',
226
255
 
256
+ // ── 组长条(主会话 / 工作区组长,v0.2.0)────────────────────
257
+ '.tb-leads{display:flex;align-items:center;gap:2px 10px;flex-wrap:wrap;padding:7px 10px;background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-md);font:var(--dsw-font-xxxs-11);min-width:0}',
258
+ '.tb-lead{display:inline-flex;align-items:center;gap:5px;min-width:0;flex-wrap:wrap}',
259
+ '.tb-lead + .tb-lead{padding-left:10px;border-left:1px solid var(--dsw-alias-border-l1)}',
260
+ '.tb-lead-dot{width:7px;height:7px;border-radius:50%;flex:0 0 auto;background:var(--dsw-alias-state-success-primary)}',
261
+ '.tb-lead-dot[data-status=busy]{background:var(--dsw-alias-state-warn-primary)}',
262
+ '.tb-lead-dot[data-status=offline],.tb-lead-dot[data-status=missing],.tb-lead-dot[data-status=archived]{background:var(--dsw-alias-label-tertiary)}',
263
+ '.tb-lead-label{color:var(--dsw-alias-label-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:230px}',
264
+ '.tb-lead-state{color:var(--dsw-alias-label-tertiary);white-space:nowrap}',
265
+ '.tb-lead-hint{flex-basis:100%;color:var(--dsw-alias-label-tertiary);line-height:1.45}',
266
+ '.tb-lead-btn{height:22px;padding:0 8px}',
267
+ '.tb-page[data-narrow=true] .tb-leads{padding:5px 8px;gap:2px 8px}',
268
+ '.tb-page[data-narrow=true] .tb-lead-label{max-width:160px}',
269
+
227
270
 
228
271
  // ── Apple 风格皮肤(最后追加,覆盖上面的基础样式)──────────
229
272
  // 设计参照 macOS / iOS:灰色画布 + 白色卡片、发丝分隔线、胶囊按钮、系统字体、柔和阴影。
@@ -272,17 +315,20 @@ window.__ModuleLoader__.load({
272
315
  '.tb-card{background:var(--tb-surface);border:1px solid var(--tb-hairline-soft);border-left:1px solid var(--tb-hairline-soft);border-radius:var(--dsw-radius-md,12px);padding:10px 11px;box-shadow:var(--tb-shadow-1);transition:box-shadow .18s ease,transform .18s ease,border-color .18s ease}',
273
316
  '.tb-card:hover{box-shadow:var(--tb-shadow-2);border-color:var(--tb-hairline);transform:translateY(-1px)}',
274
317
  '.tb-card-title{font:600 12.5px/1.45 var(--dsh-font-family-text-default,-apple-system,sans-serif);color:var(--tb-text);letter-spacing:0}',
275
- '.tb-card-note{color:var(--tb-text-2);font-size:11.5px;line-height:1.5}',
276
- '.tb-card-result{color:var(--tb-text-2);font-size:10.5px}',
277
- '.tb-card-error{color:var(--tb-danger);font-size:10.5px}',
278
- '.tb-card-meta{color:var(--tb-text-3);font-size:10px;gap:6px;margin-top:6px}',
279
- '.tb-card-tag{background:var(--dsw-alias-bg-skeleton);border:0;border-radius:5px;padding:0 5px;font-size:9.5px;color:var(--tb-text-2);line-height:15px}',
280
- '.tb-card-actions{gap:6px;margin-top:8px}',
281
318
  '.tb-empty{color:var(--tb-text-3);font-size:11px;padding:12px 6px;text-align:center;border:0;background:transparent}',
282
319
  '.tb-foot{color:var(--tb-text-3);font-size:10px;padding-top:2px;border-top:1px solid var(--tb-hairline-soft)}',
283
320
  '.tb-foot code{background:var(--dsw-alias-bg-skeleton);border-radius:5px;padding:1px 5px;font-size:9.5px}',
284
321
  '.tb-wsname{color:var(--tb-text-2);font-size:10.5px}',
285
322
  '.tb-toolbar-filter,.tb-toolbar-count{color:var(--tb-text-3);font-size:10.5px}',
323
+ // 组长条:与卡片同一套表面(颜色全部走官方 --dsw-* 主题变量)
324
+ '.tb-leads{background:var(--dsw-alias-bg-base);border:1px solid var(--dsw-alias-border-l1);border-radius:12px;padding:7px 10px;box-shadow:var(--tb-shadow-1)}',
325
+ '.tb-lead + .tb-lead{border-left-color:var(--dsw-alias-border-l1)}',
326
+ '.tb-lead-label{color:var(--dsw-alias-label-secondary)}',
327
+ '.tb-lead-state,.tb-lead-hint{color:var(--dsw-alias-label-tertiary)}',
328
+ // 组长条按钮与同行文字统一字体/字号/行高/字重:按钮默认 500 字重 + 另一套
329
+ // 字体族 + line-height:1,会让「打开」「把当前对话设为主会话」比「组长 · xxx」
330
+ // 低约 1px(上下不齐)。这里改成完全继承组长条正文排版。
331
+ '.tb-leads .tb-lead-btn{font-family:inherit;font-size:inherit;font-weight:400;line-height:inherit}',
286
332
  // 详情浮层:灰色画布 + 白色分组卡片
287
333
  '.tb-detail-mask{background:rgba(15,17,21,.28);backdrop-filter:blur(12px) saturate(140%);padding:20px}',
288
334
  '.tb-detail{background:var(--tb-surface);border:1px solid var(--tb-hairline);border-radius:18px;box-shadow:0 30px 90px rgba(15,17,21,.28)}',
@@ -326,6 +372,18 @@ window.__ModuleLoader__.load({
326
372
  '.tb-rich .tb-rich-hr{border-top:1px solid var(--tb-hairline-soft)}',
327
373
  '.tb-rich a{color:var(--dsw-alias-link,var(--tb-accent));text-decoration:none}',
328
374
  '.tb-rich a:hover{text-decoration:underline}',
375
+
376
+ // ── 卡片精简 + 等高(t-33 / t-42)────────────────────────────
377
+ // 卡片正文只剩标题,高度由内容决定(t-42 去掉了整卡 min-height:108px + 操作行
378
+ // margin-top:auto——那两条会把 2 行标题的卡片撑高,多余高度全变成标题与按钮之间的空行)。
379
+ // 等高改用「标题固定 2 行高度」:1 行标题与 2 行标题的标题块都是 2.8em(12.5px × 1.4 × 2
380
+ // = 35px),标题与操作行之间只留 .tb-card-fixed 的 gap:5px,不再有整块空行。
381
+ // 窄栏按钮换 2 行时卡片会变高(不裁按钮的取舍);标题 2 行截断(line-clamp),
382
+ // 全文放 title 属性;行内编辑态不带 .tb-card-fixed,高度自适应。
383
+ '.tb-card-fixed{gap:5px;padding:9px 10px 8px}',
384
+ '.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}',
385
+ '.tb-card-fixed .tb-card-actions{gap:3px 4px;padding-top:0}',
386
+ '.tb-card-fixed .tb-card-actions .tb-btn{height:22px;padding:0 7px;font-size:10.5px}',
329
387
  ].join('\n')
330
388
 
331
389
  function injectCss() {
@@ -348,7 +406,6 @@ window.__ModuleLoader__.load({
348
406
  'guide.description': '看板在右侧栏里:待开始 / 进行中 / 已完成 / 已归档,主 Agent 会自动挑待开始的任务派发。',
349
407
  'action.openBoard': '打开任务看板(右侧栏)',
350
408
  'page.title': '任务看板',
351
- 'page.subtitle': '主 Agent 只派单、子 Agent 干活。待开始列会被自动轮询派发。',
352
409
  'page.refresh': '刷新',
353
410
  'page.refreshing': '刷新中…',
354
411
  'poll.on': '每 {interval} 轮询',
@@ -360,10 +417,11 @@ window.__ModuleLoader__.load({
360
417
  'poll.resume': '恢复轮询',
361
418
  'poll.interval': '间隔',
362
419
  'dispatch.mode': '派发到',
420
+ 'dispatch.mode.workspace-lead': '工作区组长(推荐)',
363
421
  'dispatch.mode.new': '新对话',
364
422
  'dispatch.mode.creator': '回发起对话',
365
423
  'dispatch.mode.auto': '空闲会话',
366
- 'dispatch.modeHint': '新对话:每个任务在它自己的工作区新开一个对话执行(推荐);回发起对话:派回创建它的那个对话;空闲会话:自动挑一个空闲会话。',
424
+ 'dispatch.modeHint': '工作区组长:任务交给所属工作区的常驻组长执行(推荐);新对话:每个任务在它自己的工作区新开一个对话执行;回发起对话:派回创建它的那个对话;空闲会话:自动挑一个空闲会话。',
367
425
  'poll.skip.poll-disabled': '轮询已暂停',
368
426
  'poll.skip.agent-busy': '目标会话正在运行,稍后自动重试',
369
427
  'poll.skip.agent-offline': '任务指定的会话不在线',
@@ -376,10 +434,17 @@ window.__ModuleLoader__.load({
376
434
  'composer.addNote': '加备注',
377
435
  'composer.hideNote': '收起备注',
378
436
  'composer.submit': '添加到待开始',
437
+ 'composer.uploading': '图片上传中…',
438
+ 'composer.removeImage': '移除图片',
439
+ 'composer.imageTooMany': '一次最多粘贴 {n} 张图片,请分次粘贴',
440
+ 'composer.imageTooLarge': '单张图片不能超过 {mb} MB,已跳过 {n} 张',
441
+ 'composer.attachmentTooMany': '一条任务最多 {max} 个图片附件(当前 {n} 个)',
442
+ 'composer.imageFailed': '读取剪贴板图片失败',
379
443
  'composer.autoHint': '加进「待开始」后由主 Agent 自动接手,你只管加任务和看结论。',
380
444
  'composer.autoHintWorkspace': '加进「待开始」后由主 Agent 自动接手;任务会回到本对话执行(工作区:{name})。',
381
- 'card.workspace': '工作区 {name}',
382
445
  'composer.empty': '先写任务标题',
446
+ 'detail.imageLoading': '图片加载中…',
447
+ 'detail.imageFailed': '图片不可用',
383
448
  'column.todo': '待开始',
384
449
  'column.doing': '进行中',
385
450
  'column.done': '已完成',
@@ -400,15 +465,14 @@ window.__ModuleLoader__.load({
400
465
  'card.delete': '删除',
401
466
  'card.save': '保存',
402
467
  'card.cancel': '取消',
403
- 'card.deleteConfirm': '删除任务「{title}」?',
404
468
  'card.deleteConfirmShort': '确认删除',
405
469
  'card.detail': '详情',
406
470
  'card.openChat': '对话',
407
471
  'detail.sessions': '关联对话',
408
472
  'detail.creatorSession': '发起对话',
409
473
  'detail.runSession': '执行对话',
474
+ 'detail.leadSession': '组长对话',
410
475
  'detail.noSession': '(这条任务还没有关联对话)',
411
- 'detail.status': '状态',
412
476
  'detail.basicInfo': '基本信息',
413
477
  'detail.timeline': '时间线',
414
478
  'detail.workspace': '工作区',
@@ -422,7 +486,6 @@ window.__ModuleLoader__.load({
422
486
  'detail.source': '创建来源',
423
487
  'detail.sourceUser': '用户(看板 / 对话)',
424
488
  'detail.sourceAgent': '主 Agent(模型工具)',
425
- 'detail.notify': '派发提醒次数',
426
489
  'detail.id': '任务 id',
427
490
  'detail.note': '备注 / 验收标准',
428
491
  'detail.result': '完成结论',
@@ -431,15 +494,12 @@ window.__ModuleLoader__.load({
431
494
  'detail.emptyResult': '任务已完成,但主 Agent 还没有写结论。',
432
495
  'detail.emptyResultPending': '任务还没完成,完成后主 Agent 会把结论写在这里。',
433
496
  'detail.close': '关闭',
434
- 'card.assignee': '执行者',
435
- 'card.result': '结论',
436
- 'card.notified': '已通知 {n} 次',
437
497
  'card.ago.now': '刚刚',
438
498
  'card.ago.min': '{n} 分钟前',
439
499
  'card.ago.hour': '{n} 小时前',
440
500
  'card.ago.day': '{n} 天前',
441
- 'banner.presetMissing': '没有找到「派单看板模式」:{reason}',
442
- 'banner.presetBroken': '派单看板模式加载失败:{reason}',
501
+ 'banner.presetMissing': '没有找到「任务看板 · 工作区组长(自动)」:{reason}',
502
+ 'banner.presetBroken': '任务看板 · 工作区组长(自动)加载失败:{reason}',
443
503
  'banner.error': '连接看板服务失败:{message}',
444
504
  'banner.retrying': '连接断开,正在重试…',
445
505
  'action.archived': '已归档 {n} 个任务',
@@ -479,6 +539,34 @@ window.__ModuleLoader__.load({
479
539
  'poll.skip.workspace-offline': '这条任务所属工作区没有打开的对话:先在那个工作区开一个对话,或点「立即派发」改派',
480
540
  'poll.skip.creator-busy': '创建这条任务的对话正在运行,等它空下来再派',
481
541
  'poll.skip.creator-cold': '创建这条任务的对话还没激活(历史会话):在那边发一条消息,任务就会回到该对话执行;急的话点「立即派发」',
542
+ // v0.2.0 workspace-lead 路由的跳过原因(poll.lastSkipReason)
543
+ 'poll.skip.lead-busy': '工作区组长正在运行,等它空下来再派',
544
+ 'poll.skip.lead-unavailable': '工作区组长不可用:稍后重试,或在看板点「创建组长」',
545
+ 'poll.skip.lead-no-workspace': '无法解析任务的工作区:请从目标工作区的会话里重新加这条任务',
546
+
547
+ // v0.2.0 组长条 / 主会话绑定
548
+ 'lead.barLabel': '组长条',
549
+ 'lead.mainLabel': '主会话 · {title}',
550
+ 'lead.mainFallback': '主会话',
551
+ 'lead.unbound': '未绑定主会话',
552
+ 'lead.bind': '把当前对话设为主会话',
553
+ 'lead.rebind': '换绑',
554
+ 'lead.clear': '解除绑定',
555
+ 'lead.open': '打开',
556
+ 'lead.wsLabel': '组长 · {label}',
557
+ 'lead.wsFallback': '工作区',
558
+ 'lead.create': '创建组长',
559
+ 'lead.status.online': '在线',
560
+ 'lead.status.busy': '忙',
561
+ 'lead.status.offline': '离线',
562
+ 'lead.status.missing': '未创建',
563
+ 'lead.status.archived': '已归档',
564
+ 'lead.noCurrentSession': '拿不到当前会话 id:先在这个对话里打开右侧栏看板,再绑定主会话',
565
+ 'lead.bindOk': '已把当前对话设为主会话',
566
+ 'lead.clearOk': '已解除主会话绑定',
567
+ 'lead.ensureOk': '已创建工作区组长',
568
+ 'detail.lead': '组长',
569
+ 'detail.noLead': '(还没有组长)',
482
570
  }
483
571
 
484
572
  const DICT_EN = {
@@ -486,7 +574,6 @@ window.__ModuleLoader__.load({
486
574
  'guide.description': 'The board lives in this right sidebar: todo / in progress / done / archived, and the main agent dispatches todo tasks for you.',
487
575
  'action.openBoard': 'Open task board (right sidebar)',
488
576
  'page.title': 'Task board',
489
- 'page.subtitle': 'The main agent dispatches, subagents do the work. Todo tasks are polled and dispatched automatically.',
490
577
  'page.refresh': 'Refresh',
491
578
  'page.refreshing': 'Refreshing…',
492
579
  'poll.on': 'Polling every {interval}',
@@ -498,10 +585,11 @@ window.__ModuleLoader__.load({
498
585
  'poll.resume': 'Resume polling',
499
586
  'poll.interval': 'Interval',
500
587
  'dispatch.mode': 'Dispatch to',
588
+ 'dispatch.mode.workspace-lead': 'Workspace lead (recommended)',
501
589
  'dispatch.mode.new': 'New chat',
502
590
  'dispatch.mode.creator': 'Creator chat',
503
591
  'dispatch.mode.auto': 'Idle chat',
504
- 'dispatch.modeHint': 'New chat: start a fresh conversation in the task workspace (recommended); Creator chat: reuse the conversation that created it; Idle chat: pick any idle conversation.',
592
+ 'dispatch.modeHint': 'Workspace lead: hand the task to the resident lead of its workspace (recommended); New chat: start a fresh conversation in the task workspace; Creator chat: reuse the conversation that created it; Idle chat: pick any idle conversation.',
505
593
  'poll.skip.poll-disabled': 'Polling paused',
506
594
  'poll.skip.agent-busy': 'Target session is busy; retrying later',
507
595
  'poll.skip.agent-offline': 'The task session is offline',
@@ -514,10 +602,17 @@ window.__ModuleLoader__.load({
514
602
  'composer.addNote': 'Add notes',
515
603
  'composer.hideNote': 'Hide notes',
516
604
  'composer.submit': 'Add to todo',
605
+ 'composer.uploading': 'Uploading image…',
606
+ 'composer.removeImage': 'Remove image',
607
+ 'composer.imageTooMany': 'At most {n} images per paste; paste them in smaller batches',
608
+ 'composer.imageTooLarge': 'Each image must be {mb} MB or smaller; skipped {n}',
609
+ 'composer.attachmentTooMany': 'At most {max} image attachments per task (currently {n})',
610
+ 'composer.imageFailed': 'Could not read the clipboard image',
517
611
  'composer.autoHint': 'The main agent picks up new todo tasks automatically — just add tasks and read the results.',
518
612
  'composer.autoHintWorkspace': 'The main agent picks this up automatically and runs it back in this conversation (workspace: {name}).',
519
- 'card.workspace': 'workspace {name}',
520
613
  'composer.empty': 'Title is required',
614
+ 'detail.imageLoading': 'Loading image…',
615
+ 'detail.imageFailed': 'Image unavailable',
521
616
  'column.todo': 'Todo',
522
617
  'column.doing': 'In progress',
523
618
  'column.done': 'Done',
@@ -538,15 +633,14 @@ window.__ModuleLoader__.load({
538
633
  'card.delete': 'Delete',
539
634
  'card.save': 'Save',
540
635
  'card.cancel': 'Cancel',
541
- 'card.deleteConfirm': 'Delete task "{title}"?',
542
636
  'card.deleteConfirmShort': 'Confirm delete',
543
637
  'card.detail': 'Details',
544
638
  'card.openChat': 'Chat',
545
639
  'detail.sessions': 'Linked conversations',
546
640
  'detail.creatorSession': 'Created in',
547
641
  'detail.runSession': 'Dispatched to',
642
+ 'detail.leadSession': 'Lead conversation',
548
643
  'detail.noSession': '(this task has no linked conversation yet)',
549
- 'detail.status': 'Status',
550
644
  'detail.basicInfo': 'Details',
551
645
  'detail.timeline': 'Timeline',
552
646
  'detail.workspace': 'Workspace',
@@ -560,7 +654,6 @@ window.__ModuleLoader__.load({
560
654
  'detail.source': 'Created by',
561
655
  'detail.sourceUser': 'User (board or chat)',
562
656
  'detail.sourceAgent': 'Main agent (model tool)',
563
- 'detail.notify': 'Dispatch reminders',
564
657
  'detail.id': 'Task id',
565
658
  'detail.note': 'Note / acceptance',
566
659
  'detail.result': 'Result',
@@ -569,15 +662,12 @@ window.__ModuleLoader__.load({
569
662
  'detail.emptyResult': 'Task is done but the main agent has not written a result yet.',
570
663
  'detail.emptyResultPending': 'Not finished yet; the main agent writes the result here when done.',
571
664
  'detail.close': 'Close',
572
- 'card.assignee': 'Assignee',
573
- 'card.result': 'Result',
574
- 'card.notified': 'Notified {n} times',
575
665
  'card.ago.now': 'just now',
576
666
  'card.ago.min': '{n} min ago',
577
667
  'card.ago.hour': '{n} h ago',
578
668
  'card.ago.day': '{n} d ago',
579
- 'banner.presetMissing': 'Dispatcher mode not found: {reason}',
580
- 'banner.presetBroken': 'Dispatcher mode failed to load: {reason}',
669
+ 'banner.presetMissing': 'Task-board workspace-lead mode not found: {reason}',
670
+ 'banner.presetBroken': 'Task-board workspace-lead mode failed to load: {reason}',
581
671
  'banner.error': 'Cannot reach the task board service: {message}',
582
672
  'banner.retrying': 'Connection lost, retrying…',
583
673
  'action.archived': 'Archived {n} tasks',
@@ -617,6 +707,34 @@ window.__ModuleLoader__.load({
617
707
  'poll.skip.workspace-offline': 'No open conversation in the task workspace: open one there, or click Dispatch now',
618
708
  'poll.skip.creator-busy': 'The conversation that created this task is running; retrying later',
619
709
  'poll.skip.creator-cold': 'The creating conversation is not active yet (legacy session): send a message there to receive the task, or click Dispatch now',
710
+ // v0.2.0 workspace-lead routing skip reasons (poll.lastSkipReason)
711
+ 'poll.skip.lead-busy': 'The workspace lead is running; it will retry once it is idle',
712
+ 'poll.skip.lead-unavailable': 'The workspace lead is unavailable: retry later, or click Create lead on the board',
713
+ 'poll.skip.lead-no-workspace': 'Cannot resolve the task workspace: re-add this task from a conversation inside the target workspace',
714
+
715
+ // v0.2.0 lead bar / main-session binding
716
+ 'lead.barLabel': 'Team leads',
717
+ 'lead.mainLabel': 'Main · {title}',
718
+ 'lead.mainFallback': 'Main',
719
+ 'lead.unbound': 'Main session not bound',
720
+ 'lead.bind': 'Set this chat as main session',
721
+ 'lead.rebind': 'Rebind',
722
+ 'lead.clear': 'Unbind',
723
+ 'lead.open': 'Open',
724
+ 'lead.wsLabel': 'Lead · {label}',
725
+ 'lead.wsFallback': 'workspace',
726
+ 'lead.create': 'Create lead',
727
+ 'lead.status.online': 'online',
728
+ 'lead.status.busy': 'busy',
729
+ 'lead.status.offline': 'offline',
730
+ 'lead.status.missing': 'not created',
731
+ 'lead.status.archived': 'archived',
732
+ 'lead.noCurrentSession': 'Current session id is unavailable: open this board from a conversation first, then bind the main session',
733
+ 'lead.bindOk': 'This conversation is now the main session',
734
+ 'lead.clearOk': 'Main session unbound',
735
+ 'lead.ensureOk': 'Workspace lead created',
736
+ 'detail.lead': 'Lead',
737
+ 'detail.noLead': '(no lead yet)',
620
738
  }
621
739
 
622
740
  function detectLang(locale) {
@@ -790,6 +908,172 @@ window.__ModuleLoader__.load({
790
908
  return sessionId.length > 8 ? sessionId.slice(-8) : sessionId
791
909
  }
792
910
 
911
+ // 会话 id 只认两种形态:`session-<id>`(宿主会话)与裸 UUID(宿主 `subagentId` 就是会话 UUID)。
912
+ // 任务 `assignee` 是自由文本,组长也可能写 `worker-42` / `main` 这类普通标签,那些不是会话。
913
+ 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
914
+ // 从自由文本里找会话 id token 用:不带锚点,但两侧边界不能是 `[A-Za-z0-9_-]`(见 extractSessionId)。
915
+ 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
916
+ const SESSION_TOKEN_EDGE = /[A-Za-z0-9_-]/
917
+
918
+ /** 整串就是会话 id(严格判定,不做提取)。 */
919
+ function looksLikeSessionId(value) {
920
+ return typeof value === 'string' && SESSION_ID_PATTERN.test(value.trim())
921
+ }
922
+
923
+ /**
924
+ * 从 `assignee` 这类自由文本里提取第一个会话 id(t-39 增量):
925
+ * 组长常把 id 写成 `5a6b…(worker)` / `… (worker)` / `…@worker` / `worker: …`,
926
+ * 整串严格匹配会漏掉 → 卡片回退组长会话。这里按 token 扫描,返回 id 本身(保留原始大小写)。
927
+ * 边界:token 前后不能紧邻 `[A-Za-z0-9_-]`,所以 `worker-42` / `main` / 中文标签 /
928
+ * `session-`(dash 后没有 id)/ 被别的词粘住的片段都不算会话,返回空串。
929
+ */
930
+ function extractSessionId(value) {
931
+ if (typeof value !== 'string') return ''
932
+ const text = value.trim()
933
+ if (text === '') return ''
934
+ if (looksLikeSessionId(text)) return text
935
+ SESSION_TOKEN_PATTERN.lastIndex = 0
936
+ let match = SESSION_TOKEN_PATTERN.exec(text)
937
+ while (match !== null) {
938
+ const end = match.index + match[0].length
939
+ const before = match.index > 0 ? text.charAt(match.index - 1) : ''
940
+ const after = end < text.length ? text.charAt(end) : ''
941
+ if (!SESSION_TOKEN_EDGE.test(before) && !SESSION_TOKEN_EDGE.test(after)) return match[0]
942
+ match = SESSION_TOKEN_PATTERN.exec(text)
943
+ }
944
+ return ''
945
+ }
946
+
947
+ /**
948
+ * 任务真正的「执行对话」(worker 子会话):组长直聊派活时把 worker 会话 id 写进 `task.assignee`(§1.8),
949
+ * 但 `assignee` 也可能是普通标签 —— 只有文本里能提取到会话 id 时才返回,否则返回空串(不当会话打开)。
950
+ */
951
+ function workerSessionOf(task) {
952
+ if (!task || typeof task !== 'object') return ''
953
+ return extractSessionId(task.assignee)
954
+ }
955
+
956
+ /* ── v0.2.0 组长条(主会话 / 工作区组长)纯展示函数 ───────── */
957
+
958
+ // 「派发到」的四个合法值:v0.2.0 起默认 workspace-lead(缺省 / 未知一律回退它,不要回退 new)。
959
+ const DISPATCH_MODES = ['workspace-lead', 'new', 'creator', 'auto']
960
+
961
+ function dispatchModeOf(config) {
962
+ const mode = config && typeof config.dispatchMode === 'string' ? config.dispatchMode : ''
963
+ return DISPATCH_MODES.indexOf(mode) >= 0 ? mode : 'workspace-lead'
964
+ }
965
+
966
+ /** 组长 / 主会话状态点:missing(没有会话/未创建)/ offline(离线)/ busy(忙)/ online(在线)。 */
967
+ function leadStatusKey(lead) {
968
+ if (!lead || typeof lead !== 'object') return 'missing'
969
+ const sessionId = typeof lead.sessionId === 'string' ? lead.sessionId : ''
970
+ if (sessionId === '') return 'missing'
971
+ // 会话被归档:dsh 的归档门会拒绝它跑模型步进,任何调度都无效(v0.2.1)。
972
+ if (lead.archived === true) return 'archived'
973
+ // 没有 live 字段(旧 Host / 数据不完整)按离线处理,不误报绿点。
974
+ if (lead.live !== true) return 'offline'
975
+ if (lead.busy === true) return 'busy'
976
+ return 'online'
977
+ }
978
+
979
+ /** 主会话 / 组长展示名:title 取尾部 8 个字符,空串用 fallback(主会话的回退文案是「主会话」)。 */
980
+ function leadTitleTail(title, fallback) {
981
+ const text = typeof title === 'string' ? title.trim() : ''
982
+ const tail = text === '' ? '' : text.length > 8 ? text.slice(-8) : text
983
+ if (tail !== '') return tail
984
+ return typeof fallback === 'string' ? fallback : ''
985
+ }
986
+
987
+ /** 组长条的主会话一行:未绑定(leads.main 为 null)返回 null。 */
988
+ function leadMainRow(leads) {
989
+ const main = leads && typeof leads === 'object' ? leads.main : null
990
+ if (!main || typeof main !== 'object') return null
991
+ const sessionId = typeof main.sessionId === 'string' ? main.sessionId : ''
992
+ if (sessionId === '') return null
993
+ return {
994
+ sessionId,
995
+ title: typeof main.title === 'string' ? main.title : '',
996
+ status: leadStatusKey(main),
997
+ }
998
+ }
999
+
1000
+ /** 任务卡片 / 详情的「组长」文案:优先 dispatchedSessionTitle,其次会话 id 尾 8;都没有返回空串。 */
1001
+ function taskLeadLabel(task) {
1002
+ if (!task || typeof task !== 'object') return ''
1003
+ const title = typeof task.dispatchedSessionTitle === 'string' ? task.dispatchedSessionTitle.trim() : ''
1004
+ if (title !== '') return title
1005
+ const sessionId = typeof task.dispatchedSessionId === 'string' ? task.dispatchedSessionId : ''
1006
+ return sessionId !== '' ? shortSession(sessionId) : ''
1007
+ }
1008
+
1009
+ /** 看板可见任务涉及的工作区路径(去重;当前会话工作区排最前,保证没有任务也能「创建组长」)。 */
1010
+ function taskWorkspaceCwds(tasks, currentCwd) {
1011
+ const out = []
1012
+ const push = (cwd) => {
1013
+ if (typeof cwd !== 'string' || cwd === '') return
1014
+ if (out.some((item) => samePath(item, cwd))) return
1015
+ out.push(cwd)
1016
+ }
1017
+ push(currentCwd)
1018
+ for (const task of Array.isArray(tasks) ? tasks : []) {
1019
+ if (task) push(task.cwd)
1020
+ }
1021
+ return out
1022
+ }
1023
+
1024
+ /**
1025
+ * 组长条的工作区行(数据来自 Snapshot.leads,运行时视图):
1026
+ * - all=true(完整看板):列出 snapshot.leads.workspaces 全部条目;
1027
+ * - all=false(右栏本工作区看板):只列当前看板可见任务涉及的工作区
1028
+ * (task.cwd 归一化 / 工作区 id 与组长条目的 cwd / key 比对,兼容两者),
1029
+ * 没有组长的补一行 missing,让用户能点「创建组长」(ensure-workspace-lead)。
1030
+ */
1031
+ function workspaceLeadRows(leads, cwds, options) {
1032
+ const all = !!(options && options.all)
1033
+ const list = leads && Array.isArray(leads.workspaces) ? leads.workspaces : []
1034
+ const wanted = (Array.isArray(cwds) ? cwds : []).filter((cwd) => typeof cwd === 'string' && cwd !== '')
1035
+ const rows = []
1036
+ const seen = []
1037
+ for (const entry of list) {
1038
+ if (!entry || typeof entry !== 'object') continue
1039
+ const key = typeof entry.key === 'string' ? entry.key : ''
1040
+ const cwd = typeof entry.cwd === 'string' ? entry.cwd : ''
1041
+ if (!all) {
1042
+ const matches = wanted.some(
1043
+ (want) => samePath(want, cwd) || (key !== '' && samePath(want, key)),
1044
+ )
1045
+ if (!matches) continue
1046
+ }
1047
+ const status = leadStatusKey(entry)
1048
+ rows.push({
1049
+ key: key !== '' ? key : cwd,
1050
+ label: typeof entry.label === 'string' && entry.label !== '' ? entry.label : baseName(cwd),
1051
+ cwd,
1052
+ sessionId: typeof entry.sessionId === 'string' ? entry.sessionId : '',
1053
+ title: typeof entry.title === 'string' ? entry.title : '',
1054
+ status,
1055
+ missing: status === 'missing',
1056
+ })
1057
+ if (cwd !== '') seen.push(cwd)
1058
+ }
1059
+ if (!all) {
1060
+ for (const cwd of wanted) {
1061
+ if (seen.some((item) => samePath(item, cwd))) continue
1062
+ rows.push({
1063
+ key: normalizePath(cwd),
1064
+ label: baseName(cwd),
1065
+ cwd,
1066
+ sessionId: '',
1067
+ title: '',
1068
+ status: 'missing',
1069
+ missing: true,
1070
+ })
1071
+ seen.push(cwd)
1072
+ }
1073
+ }
1074
+ return rows
1075
+ }
1076
+
793
1077
  /** 绝对时间(本地时区,YYYY-MM-DD HH:mm:ss):详情浮层用,空值显示破折号。 */
794
1078
  function fmtWhen(value) {
795
1079
  if (typeof value !== 'string' || value === '') return '—'
@@ -807,32 +1091,153 @@ window.__ModuleLoader__.load({
807
1091
  )
808
1092
  }
809
1093
 
810
- /** 行内格式:**粗体**、`代码`、[链接](url)。 */
811
- function renderInline(text, keyPrefix) {
812
- const nodes = []
813
- const pattern = /(\*\*[^*]+\*\*|`[^`]+`|\[[^\]]+\]\([^)]+\))/
814
- const parts = String(text).split(pattern)
815
- for (let i = 0; i < parts.length; i++) {
816
- const part = parts[i]
817
- if (part === '') continue
818
- if (part.startsWith('**') && part.endsWith('**') && part.length > 4) {
819
- nodes.push(h('strong', { key: keyPrefix + 'b' + i }, part.slice(2, -2)))
820
- } else if (part.startsWith('`') && part.endsWith('`') && part.length > 2) {
821
- nodes.push(h('code', { key: keyPrefix + 'c' + i }, part.slice(1, -1)))
822
- } else if (part.startsWith('[') && part.includes('](') && part.endsWith(')')) {
823
- const close = part.indexOf('](')
824
- const label = part.slice(1, close)
825
- const href = part.slice(close + 2, -1)
826
- nodes.push(
827
- /^https?:\/\//i.test(href)
828
- ? h('a', { key: keyPrefix + 'a' + i, href, target: '_blank', rel: 'noreferrer' }, label)
829
- : h('span', { key: keyPrefix + 'x' + i }, label),
830
- )
831
- } else {
832
- nodes.push(part)
1094
+ /* ── 粘贴图片附件(v0.2.0)纯函数 ─────────────────────────── */
1095
+
1096
+ // note 里的短引用固定为 ![image](attachment://<uuid>)(契约见 docs/architecture.md §2.1)。
1097
+ const ATTACHMENT_ID_SOURCE = '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
1098
+ const ATTACHMENT_REF_PATTERN = new RegExp('!\\[[^\\]]*\\]\\(attachment:\\/\\/(' + ATTACHMENT_ID_SOURCE + ')\\)', 'g')
1099
+ const MAX_PASTE_IMAGES = 4
1100
+ /** 详情浮层的附件 data URL 缓存上限(单任务最多 8 个引用;超出按插入顺序淘汰最旧的)。 */
1101
+ const MAX_ATTACHMENT_CACHE = 8
1102
+ /** 单张图片上限(与服务端 MAX_ATTACHMENT_BYTES 同值,§2.1):粘贴前按 file.size 预检,超限不发请求。 */
1103
+ const MAX_ATTACHMENT_BYTES = 5 * 1024 * 1024
1104
+ const MAX_ATTACHMENT_MB = MAX_ATTACHMENT_BYTES / (1024 * 1024)
1105
+ /** 单条任务 note 里最多几个不同附件引用(与服务端 MAX_TASK_ATTACHMENTS 同值,§2.1)。 */
1106
+ const MAX_NOTE_ATTACHMENTS = 8
1107
+
1108
+ function attachmentRef(id) {
1109
+ return '![image](attachment://' + String(id) + ')'
1110
+ }
1111
+
1112
+ /** 从若干段文本里按出现顺序取出去重的附件 id。 */
1113
+ function attachmentIdsIn() {
1114
+ const ids = []
1115
+ for (let i = 0; i < arguments.length; i += 1) {
1116
+ const text = arguments[i]
1117
+ if (typeof text !== 'string' || text === '') continue
1118
+ ATTACHMENT_REF_PATTERN.lastIndex = 0
1119
+ let match
1120
+ while ((match = ATTACHMENT_REF_PATTERN.exec(text)) !== null) {
1121
+ if (ids.indexOf(match[1]) === -1) ids.push(match[1])
833
1122
  }
834
1123
  }
835
- return nodes
1124
+ return ids
1125
+ }
1126
+
1127
+ /** 在备注末尾追加短引用(不重复追加同一 id)。 */
1128
+ function insertAttachmentRef(note, id) {
1129
+ const text = typeof note === 'string' ? note : ''
1130
+ const ref = attachmentRef(id)
1131
+ if (text.indexOf(ref) !== -1) return text
1132
+ const head = text.replace(/\s+$/, '')
1133
+ return head === '' ? ref : head + '\n' + ref
1134
+ }
1135
+
1136
+ /** 删除备注里的某个短引用(用于移除待提交图片)。 */
1137
+ function removeAttachmentRef(note, id) {
1138
+ const text = typeof note === 'string' ? note : ''
1139
+ const ref = attachmentRef(id)
1140
+ const escaped = ref.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
1141
+ return text
1142
+ .replace(new RegExp(escaped, 'g'), '')
1143
+ .replace(/[ \t]+\n/g, '\n')
1144
+ .replace(/\n{3,}/g, '\n\n')
1145
+ .trim()
1146
+ }
1147
+
1148
+ /**
1149
+ * 粘贴图片预算:先按单图大小上限(file.size 预检)剔除超限图片——超限的图不上传、不发请求,
1150
+ * 免得撞上 7 MB 请求体上限后只显示「网络错误」;再按一次粘贴最多 MAX_PASTE_IMAGES 张截断。
1151
+ * 返回 { accepted, tooLarge, skipped }。
1152
+ */
1153
+ function splitPasteImages(files) {
1154
+ const list = Array.isArray(files) ? files : []
1155
+ const withinSize = []
1156
+ let tooLarge = 0
1157
+ for (const file of list) {
1158
+ const size = file && typeof file.size === 'number' && Number.isFinite(file.size) ? file.size : 0
1159
+ if (size > MAX_ATTACHMENT_BYTES) {
1160
+ tooLarge += 1
1161
+ continue
1162
+ }
1163
+ withinSize.push(file)
1164
+ }
1165
+ const accepted = withinSize.slice(0, MAX_PASTE_IMAGES)
1166
+ return { accepted, tooLarge, skipped: withinSize.length - accepted.length }
1167
+ }
1168
+
1169
+ /** 上传计数 > 0:连续多次粘贴时只有全部结束才解除禁用(§5.2)。 */
1170
+ function isUploading(count) {
1171
+ return typeof count === 'number' && Number.isFinite(count) && count > 0
1172
+ }
1173
+
1174
+ /** 提交闸门:Enter 与提交按钮共用(上传中 / 忙 / 标题空 / 平台看板未选工作区都不提交)。 */
1175
+ function submitBlocked(flags) {
1176
+ const value = flags || {}
1177
+ if (isUploading(value.uploading)) return true
1178
+ if (value.busy) return true
1179
+ if (typeof value.title !== 'string' || value.title.trim() === '') return true
1180
+ return value.workspaceRequired === true
1181
+ }
1182
+
1183
+ /** note 里不同附件引用数超限时的具体提示(与服务端 bad-request 文案同源,§2.1);未超限返回 ''。 */
1184
+ function noteAttachmentLimitText(t, note) {
1185
+ const count = attachmentIdsIn(note).length
1186
+ if (count <= MAX_NOTE_ATTACHMENTS) return ''
1187
+ return t('composer.attachmentTooMany', { max: MAX_NOTE_ATTACHMENTS, n: count })
1188
+ }
1189
+
1190
+ /** 剪贴板事件里的图片文件(没有图片时返回空数组,调用方保持浏览器默认粘贴行为)。 */
1191
+ function clipboardImageFiles(event) {
1192
+ const clipboard = event && event.clipboardData
1193
+ const files = []
1194
+ const items = clipboard && clipboard.items
1195
+ if (items && typeof items.length === 'number') {
1196
+ for (let i = 0; i < items.length; i += 1) {
1197
+ const item = items[i]
1198
+ if (!item || item.kind !== 'file' || !/^image\//i.test(typeof item.type === 'string' ? item.type : '')) continue
1199
+ const file = typeof item.getAsFile === 'function' ? item.getAsFile() : null
1200
+ if (file) files.push(file)
1201
+ }
1202
+ }
1203
+ // 部分浏览器只填 clipboardData.files(没有 items):补一条兜底。
1204
+ if (files.length === 0 && clipboard && clipboard.files && typeof clipboard.files.length === 'number') {
1205
+ for (let i = 0; i < clipboard.files.length; i += 1) {
1206
+ const file = clipboard.files[i]
1207
+ if (file && /^image\//i.test(typeof file.type === 'string' ? file.type : '')) files.push(file)
1208
+ }
1209
+ }
1210
+ return files
1211
+ }
1212
+
1213
+ /** File → data URL(优先 FileReader;测试 / 极简环境退回 arrayBuffer + btoa)。 */
1214
+ function fileToDataUrl(file) {
1215
+ return new Promise((resolve, reject) => {
1216
+ if (typeof FileReader === 'function') {
1217
+ try {
1218
+ const reader = new FileReader()
1219
+ reader.onload = () => resolve(typeof reader.result === 'string' ? reader.result : '')
1220
+ reader.onerror = () => reject(reader.error || new Error('read failed'))
1221
+ reader.readAsDataURL(file)
1222
+ } catch (error) {
1223
+ reject(error)
1224
+ }
1225
+ return
1226
+ }
1227
+ if (file && typeof file.arrayBuffer === 'function' && typeof btoa === 'function') {
1228
+ Promise.resolve(file.arrayBuffer()).then((buffer) => {
1229
+ const bytes = new Uint8Array(buffer)
1230
+ let binary = ''
1231
+ const step = 0x8000
1232
+ for (let i = 0; i < bytes.length; i += step) {
1233
+ binary += String.fromCharCode.apply(null, bytes.subarray(i, i + step))
1234
+ }
1235
+ resolve('data:' + (typeof file.type === 'string' && file.type !== '' ? file.type : 'image/png') + ';base64,' + btoa(binary))
1236
+ }, reject)
1237
+ return
1238
+ }
1239
+ reject(new Error('FileReader unavailable'))
1240
+ })
836
1241
  }
837
1242
 
838
1243
  /**
@@ -986,8 +1391,58 @@ window.__ModuleLoader__.load({
986
1391
  return blocks
987
1392
  }
988
1393
 
1394
+ /**
1395
+ * 行内格式:**粗体**、`代码`、[链接](url)、![图片](attachment://<id>)。
1396
+ * options.attachment(id) 返回 {status:'ready',src} / {status:'loading'|'failed'};
1397
+ * 图片引用由详情浮层按需拉取,加载中 / 失败显示占位文本。
1398
+ */
1399
+ function renderInline(text, keyPrefix, options) {
1400
+ const nodes = []
1401
+ const pattern = /(!\[[^\]]*\]\(attachment:\/\/[0-9a-f-]{36}\)|\*\*[^*]+\*\*|`[^`]+`|\[[^\]]+\]\([^)]+\))/
1402
+ const parts = String(text).split(pattern)
1403
+ for (let i = 0; i < parts.length; i++) {
1404
+ const part = parts[i]
1405
+ if (part === '') continue
1406
+ if (part.startsWith('![') && part.includes('](') && part.endsWith(')')) {
1407
+ const close = part.indexOf('](')
1408
+ const alt = part.slice(2, close)
1409
+ const href = part.slice(close + 2, -1)
1410
+ const id = href.slice('attachment://'.length)
1411
+ const hit = options && typeof options.attachment === 'function' ? options.attachment(id) : null
1412
+ if (hit && typeof hit.src === 'string' && hit.src !== '') {
1413
+ nodes.push(h('img', { key: keyPrefix + 'i' + i, className: 'tb-rich-img', src: hit.src, alt: alt || '', loading: 'lazy' }))
1414
+ } else {
1415
+ const failed = hit && hit.status === 'failed'
1416
+ nodes.push(
1417
+ h(
1418
+ 'span',
1419
+ { key: keyPrefix + 'i' + i, className: 'tb-rich-attachment' },
1420
+ (failed ? options && options.attachmentFailedText : options && options.attachmentLoadingText) || '',
1421
+ ),
1422
+ )
1423
+ }
1424
+ } else if (part.startsWith('**') && part.endsWith('**') && part.length > 4) {
1425
+ nodes.push(h('strong', { key: keyPrefix + 'b' + i }, part.slice(2, -2)))
1426
+ } else if (part.startsWith('`') && part.endsWith('`') && part.length > 2) {
1427
+ nodes.push(h('code', { key: keyPrefix + 'c' + i }, part.slice(1, -1)))
1428
+ } else if (part.startsWith('[') && part.includes('](') && part.endsWith(')')) {
1429
+ const close = part.indexOf('](')
1430
+ const label = part.slice(1, close)
1431
+ const href = part.slice(close + 2, -1)
1432
+ nodes.push(
1433
+ /^https?:\/\//i.test(href)
1434
+ ? h('a', { key: keyPrefix + 'a' + i, href, target: '_blank', rel: 'noreferrer' }, label)
1435
+ : h('span', { key: keyPrefix + 'x' + i }, label),
1436
+ )
1437
+ } else {
1438
+ nodes.push(part)
1439
+ }
1440
+ }
1441
+ return nodes
1442
+ }
1443
+
989
1444
  /** 把解析结果渲染成 React 节点(两块看板的详情浮层共用)。 */
990
- function renderRichText(text) {
1445
+ function renderRichText(text, options) {
991
1446
  const blocks = parseRichText(text)
992
1447
  return blocks.map((block, index) => {
993
1448
  const key = 'b' + index
@@ -995,12 +1450,12 @@ window.__ModuleLoader__.load({
995
1450
  return h(
996
1451
  'h4',
997
1452
  { key, className: 'tb-rich-h', 'data-level': String(block.level) },
998
- renderInline(block.text, key + '_'),
1453
+ renderInline(block.text, key + '_', options),
999
1454
  )
1000
1455
  }
1001
1456
  if (block.type === 'hr') return h('hr', { key, className: 'tb-rich-hr' })
1002
1457
  if (block.type === 'quote') {
1003
- return h('blockquote', { key, className: 'tb-rich-quote' }, renderInline(block.text, key + '_'))
1458
+ return h('blockquote', { key, className: 'tb-rich-quote' }, renderInline(block.text, key + '_', options))
1004
1459
  }
1005
1460
  if (block.type === 'code') {
1006
1461
  return h('pre', { key, className: 'tb-rich-code' }, h('code', null, block.lines.join('\n')))
@@ -1009,7 +1464,7 @@ window.__ModuleLoader__.load({
1009
1464
  return h(
1010
1465
  block.ordered ? 'ol' : 'ul',
1011
1466
  { key, className: 'tb-rich-list' },
1012
- block.items.map((item, itemIndex) => h('li', { key: key + '_' + itemIndex }, renderInline(item, key + '_' + itemIndex + '_'))),
1467
+ block.items.map((item, itemIndex) => h('li', { key: key + '_' + itemIndex }, renderInline(item, key + '_' + itemIndex + '_', options))),
1013
1468
  )
1014
1469
  }
1015
1470
  if (block.type === 'table') {
@@ -1029,7 +1484,7 @@ window.__ModuleLoader__.load({
1029
1484
  h(
1030
1485
  'th',
1031
1486
  { key: key + 'h' + cellIndex, style: { textAlign: block.aligns[cellIndex] || 'left' } },
1032
- renderInline(cell, key + 'h' + cellIndex + '_'),
1487
+ renderInline(cell, key + 'h' + cellIndex + '_', options),
1033
1488
  ),
1034
1489
  ),
1035
1490
  ),
@@ -1042,7 +1497,7 @@ window.__ModuleLoader__.load({
1042
1497
  'tr',
1043
1498
  { key: key + 'r' + rowIndex },
1044
1499
  row.map((cell, cellIndex) =>
1045
- h('td', { key: key + 'c' + cellIndex }, renderInline(cell, key + 'r' + rowIndex + 'c' + cellIndex + '_')),
1500
+ h('td', { key: key + 'c' + cellIndex }, renderInline(cell, key + 'r' + rowIndex + 'c' + cellIndex + '_', options)),
1046
1501
  ),
1047
1502
  ),
1048
1503
  ),
@@ -1054,7 +1509,7 @@ window.__ModuleLoader__.load({
1054
1509
  const children = []
1055
1510
  block.lines.forEach((lineText, lineIndex) => {
1056
1511
  if (lineIndex > 0) children.push(h('br', { key: key + 'br' + lineIndex }))
1057
- if (lineText.trim() !== '') children.push(h('span', { key: key + 'l' + lineIndex }, renderInline(lineText, key + 'l' + lineIndex + '_')))
1512
+ if (lineText.trim() !== '') children.push(h('span', { key: key + 'l' + lineIndex }, renderInline(lineText, key + 'l' + lineIndex + '_', options)))
1058
1513
  })
1059
1514
  return h('p', { key }, children)
1060
1515
  })
@@ -1169,6 +1624,126 @@ window.__ModuleLoader__.load({
1169
1624
  )
1170
1625
  }
1171
1626
 
1627
+ /** 附件上传错误:bad-request 保留宿主的具体原因(MIME / 大小上限),其它走通用 i18n。 */
1628
+ function attachmentErrorText(t, error) {
1629
+ if (error && error.code === 'bad-request' && typeof error.message === 'string' && error.message !== '') return error.message
1630
+ return errorText(t, error)
1631
+ }
1632
+
1633
+ /**
1634
+ * 备注 textarea 的 paste 处理:有图片就上传并把短引用插进备注;没有图片返回 false,
1635
+ * 调用方不 preventDefault,普通文本粘贴保持浏览器默认行为。
1636
+ * opts: { t, setNote, setPending, beginUpload, endUpload, setNotice }
1637
+ *
1638
+ * 三条边界(§5.2):
1639
+ * 1. `file.size` 预检——单图 > 5 MB 直接提示、不发请求(避免撞 7 MB 请求体后只剩「网络错误」);
1640
+ * 2. 上传用计数(beginUpload / endUpload)——连续多次粘贴时不会提前解除提交禁用;
1641
+ * 3. 逐项 catch——单个文件读取 / 上传失败不丢弃同批已成功的图片(否则会留孤儿附件 + 丢用户输入)。
1642
+ */
1643
+ function handleNotePaste(event, opts) {
1644
+ const files = clipboardImageFiles(event)
1645
+ if (files.length === 0) return false
1646
+ if (event && typeof event.preventDefault === 'function') event.preventDefault()
1647
+ const budget = splitPasteImages(files)
1648
+ if (budget.tooLarge > 0) {
1649
+ opts.setNotice({
1650
+ tone: 'warn',
1651
+ text: opts.t('composer.imageTooLarge', { mb: MAX_ATTACHMENT_MB, n: budget.tooLarge }),
1652
+ })
1653
+ }
1654
+ if (budget.accepted.length === 0) return true
1655
+ if (typeof opts.beginUpload === 'function') opts.beginUpload()
1656
+ const uploads = budget.accepted.map((file) =>
1657
+ fileToDataUrl(file).then(
1658
+ (dataUrl) =>
1659
+ callRpc('upload-attachment', {
1660
+ dataUrl,
1661
+ name: typeof file.name === 'string' ? file.name : '',
1662
+ }).then((res) => ({ res, dataUrl })),
1663
+ (error) => ({ res: null, error }),
1664
+ ),
1665
+ )
1666
+ Promise.all(uploads)
1667
+ .then(
1668
+ (pairs) => {
1669
+ const uploaded = []
1670
+ let firstError = null
1671
+ for (const pair of pairs) {
1672
+ if (pair.error) {
1673
+ if (!firstError) firstError = { code: 'internal', message: String((pair.error && pair.error.message) || pair.error) }
1674
+ continue
1675
+ }
1676
+ const res = pair.res
1677
+ if (res && res.ok === true && res.value && typeof res.value.id === 'string' && res.value.id !== '') {
1678
+ uploaded.push(Object.assign({}, res.value, { preview: pair.dataUrl }))
1679
+ } else if (!firstError) {
1680
+ firstError = (res && res.error) || { code: 'internal', message: 'malformed upload response' }
1681
+ }
1682
+ }
1683
+ if (uploaded.length > 0) {
1684
+ opts.setPending((prev) => prev.concat(uploaded))
1685
+ opts.setNote((prev) => uploaded.reduce((text, item) => insertAttachmentRef(text, item.id), prev))
1686
+ }
1687
+ if (firstError) opts.setNotice({ tone: 'error', text: attachmentErrorText(opts.t, firstError) })
1688
+ else if (budget.tooLarge === 0 && budget.skipped > 0) {
1689
+ opts.setNotice({ tone: 'warn', text: opts.t('composer.imageTooMany', { n: MAX_PASTE_IMAGES }) })
1690
+ }
1691
+ },
1692
+ (error) => {
1693
+ opts.setNotice({
1694
+ tone: 'error',
1695
+ text: opts.t('composer.imageFailed') + (error && error.message ? ':' + error.message : ''),
1696
+ })
1697
+ },
1698
+ )
1699
+ .then(() => {
1700
+ if (typeof opts.endUpload === 'function') opts.endUpload()
1701
+ })
1702
+ return true
1703
+ }
1704
+
1705
+ /** 详情浮层按需拉取 note / result 里的附件(同一 id 只请求一次;失败下次打开再试)。 */
1706
+ function loadTaskAttachments(task, sourcesRef, setSources) {
1707
+ const ids = attachmentIdsIn(task && task.note, task && task.result)
1708
+ if (ids.length === 0) return
1709
+ const current = sourcesRef.current || {}
1710
+ const loading = []
1711
+ const next = Object.assign({}, current)
1712
+ for (const id of ids) {
1713
+ const existing = current[id]
1714
+ if (existing && existing.status !== 'failed') continue
1715
+ next[id] = { status: 'loading' }
1716
+ loading.push(id)
1717
+ }
1718
+ if (loading.length === 0) return
1719
+ sourcesRef.current = next
1720
+ setSources(next)
1721
+ for (const id of loading) {
1722
+ callRpc('attachment', { id }).then((res) => {
1723
+ const value = res && res.ok === true ? res.value : null
1724
+ const entry =
1725
+ value && typeof value.dataUrl === 'string' && value.dataUrl !== ''
1726
+ ? { status: 'ready', src: value.dataUrl }
1727
+ : { status: 'failed' }
1728
+ const updated = Object.assign({}, sourcesRef.current, { [id]: entry })
1729
+ // 上限淘汰(§5.2):只淘汰已就绪的最旧条目——刚更新的这张不能挤掉自己,
1730
+ // 还在飞的 loading 占位也不能删(删了会重复发请求,且占位会闪成「加载中」)。
1731
+ let overflow = Object.keys(updated).length - MAX_ATTACHMENT_CACHE
1732
+ if (overflow > 0) {
1733
+ for (const key of Object.keys(updated)) {
1734
+ if (overflow <= 0) break
1735
+ const item = updated[key]
1736
+ if (key === id || !item || item.status === 'loading') continue
1737
+ delete updated[key]
1738
+ overflow -= 1
1739
+ }
1740
+ }
1741
+ sourcesRef.current = updated
1742
+ setSources(updated)
1743
+ })
1744
+ }
1745
+ }
1746
+
1172
1747
  /** 定时器:优先 ctx.interval,退化 window.setInterval。返回停止函数。 */
1173
1748
  function every(fn, ms) {
1174
1749
  try {
@@ -1200,6 +1775,9 @@ window.__ModuleLoader__.load({
1200
1775
  let sidebarRightService = null
1201
1776
  // 客户端导航服务:用于「跳到对应对话」。
1202
1777
  let uiWorkspaceService = null
1778
+ // 最近一次渲染过的对话会话 id:根作用域的平台看板(main)拿不到 session 绑定,
1779
+ // 用会话 header / 右栏看板渲染时记下的值当「当前对话」;拿不到就禁用主会话绑定并提示。
1780
+ let lastConversationSessionId = ''
1203
1781
 
1204
1782
  /** 在看板里直接跳到某个会话(发起对话 / 执行对话)。 */
1205
1783
  function openSessionById(sessionId) {
@@ -1232,6 +1810,51 @@ window.__ModuleLoader__.load({
1232
1810
  }
1233
1811
  }
1234
1812
 
1813
+ /**
1814
+ * 「再点一次收起」的判定:右栏已展开、且当前活动 tab 就是本插件的看板页时,返回该 TabRecord
1815
+ * (用它的 id 调 hide),否则返回 null。
1816
+ *
1817
+ * 只看右栏公开 API(0.2.2-rc.1 的 `ISidebarRight`:`active()` / `isExpanded()` / `hide(tabId)`);
1818
+ * 任一 API 缺失或抛错都当作「没开」,让点击继续走 openBoard —— 收起是锦上添花,
1819
+ * 绝不能把打开这条主路径挡掉。`TabRecord` 的形状实测为 `{ id, kind, title, contentId }`,
1820
+ * 本插件注册的页类型 kind 就是 TAB_KIND(见 §5.0)。
1821
+ */
1822
+ function expandedBoardTab() {
1823
+ if (!sidebarRightService) return null
1824
+ if (typeof sidebarRightService.active !== 'function') return null
1825
+ if (typeof sidebarRightService.isExpanded !== 'function') return null
1826
+ try {
1827
+ if (sidebarRightService.isExpanded() !== true) return null
1828
+ } catch (error) {
1829
+ return null
1830
+ }
1831
+ try {
1832
+ const tab = sidebarRightService.active()
1833
+ if (tab && typeof tab === 'object' && tab.kind === TAB_KIND && typeof tab.id === 'string') return tab
1834
+ } catch (error) {
1835
+ /* 读不到活动 tab 就按「没开」处理 */
1836
+ }
1837
+ return null
1838
+ }
1839
+
1840
+ /**
1841
+ * header 图标:看板已展开且在眼前 → 收起(docked 折叠整列 / floating 关闭浮层,tab 本身保留,
1842
+ * 下次点开还在);其它情况(没开 / 已收起 / 活动 tab 是别的)→ 照常 openTab 打开并聚焦。
1843
+ */
1844
+ function toggleBoard(retry = 0) {
1845
+ const tab = expandedBoardTab()
1846
+ if (tab && sidebarRightService && typeof sidebarRightService.hide === 'function') {
1847
+ try {
1848
+ sidebarRightService.hide(tab.id)
1849
+ return
1850
+ } catch (error) {
1851
+ // 收起失败不该变成「点了没反应」:下面照常打开。
1852
+ console.warn('[dsh-dispatch-board] 收起右侧看板失败:' + (error && error.message ? error.message : error))
1853
+ }
1854
+ }
1855
+ openBoard(retry)
1856
+ }
1857
+
1235
1858
  /* ── 图标 ───────────────────────────────────────────────── */
1236
1859
 
1237
1860
  /** 看板 glyph:会话 header 按钮、右栏 tab chip、引导页入口共用。 */
@@ -1260,6 +1883,8 @@ window.__ModuleLoader__.load({
1260
1883
 
1261
1884
  function HeaderBoardAction(props) {
1262
1885
  const sessionId = props && typeof props.sessionId === 'string' ? props.sessionId : ''
1886
+ // 顺手记下当前对话 id(幂等赋值):根作用域的平台看板靠它绑定主会话,拿不到就禁用按钮。
1887
+ if (sessionId !== '') lastConversationSessionId = sessionId
1263
1888
  const [pending, setPending] = useState(-1)
1264
1889
  // 按钮打开的是「本工作区看板」,角标也按本工作区数;拿不到工作区(冷会话)时退回全平台数。
1265
1890
  const cwdRef = useRef('')
@@ -1313,7 +1938,9 @@ window.__ModuleLoader__.load({
1313
1938
  className: 'tb-headbtn',
1314
1939
  title: tip,
1315
1940
  'aria-label': t('action.openBoard'),
1316
- onClick: openBoard,
1941
+ // 不用 openBoard 直连:onClick 会把事件对象当第一个参数传进去(retry 失效),
1942
+ // 而且这里要走「已展开就收起」的 toggle。
1943
+ onClick: () => toggleBoard(),
1317
1944
  },
1318
1945
  h(BoardGlyph, { size: 16 }),
1319
1946
  badge === null ? null : h('span', { className: 'tb-badge', 'aria-hidden': 'true' }, badge),
@@ -1344,22 +1971,40 @@ window.__ModuleLoader__.load({
1344
1971
  // 组件身份因此保持不变,2s 轮询刷新不会卸载重建它们(否则详情浮层会闪、滚动位置/编辑态会丢)。
1345
1972
 
1346
1973
  /**
1347
- * 任务关联的会话:优先「执行对话」,其次「发起对话」;
1348
1974
  * 老版本 Host 派发的进行中任务没记 dispatchedSessionId,用 snapshot.poll 的最近派发兜底
1349
- * (仅当同时只有一条 doing 任务时,避免张冠李戴)。
1975
+ * (仅当同时只有一条 doing 任务时,避免张冠李戴)。兜底会话是「派发到哪个会话」,即组长会话。
1350
1976
  */
1351
- function sessionOf(task) {
1977
+ function pollFallbackSessionOf(task) {
1352
1978
  if (!task) return ''
1353
- if (task.dispatchedSessionId) return task.dispatchedSessionId
1354
- if (task.sessionId) return task.sessionId
1355
1979
  const fallback = typeof bind.fallbackDispatchSessionId === 'string' ? bind.fallbackDispatchSessionId : ''
1356
- if (task.status === 'doing' && fallback !== '') {
1357
- const lastDispatchTaskId = typeof bind.lastDispatchTaskId === 'string' ? bind.lastDispatchTaskId : ''
1358
- if (lastDispatchTaskId === '' || lastDispatchTaskId === task.id) return fallback
1359
- }
1980
+ if (fallback === '') return ''
1981
+ if (task.status !== 'doing') return ''
1982
+ const lastDispatchTaskId = typeof bind.lastDispatchTaskId === 'string' ? bind.lastDispatchTaskId : ''
1983
+ if (lastDispatchTaskId === '' || lastDispatchTaskId === task.id) return fallback
1360
1984
  return ''
1361
1985
  }
1362
1986
 
1987
+ /** 组长会话:`dispatchedSessionId`,其次老 Host 的 poll 兜底。 */
1988
+ function leadSessionOf(task) {
1989
+ if (!task) return ''
1990
+ const dispatched = typeof task.dispatchedSessionId === 'string' ? task.dispatchedSessionId : ''
1991
+ return dispatched !== '' ? dispatched : pollFallbackSessionOf(task)
1992
+ }
1993
+
1994
+ /**
1995
+ * 任务关联的会话(卡片「对话」按钮的跳转目标),优先级:
1996
+ * worker 子会话(真正执行任务的对话)→ 组长会话(dispatchedSessionId)→ 发起对话(sessionId)
1997
+ * → 老 Host 的 poll 兜底(doing)。没有 worker 时组长会话不再冒充「执行对话」,但仍是卡片的首选跳转。
1998
+ */
1999
+ function sessionOf(task) {
2000
+ if (!task) return ''
2001
+ const worker = workerSessionOf(task)
2002
+ if (worker !== '') return worker
2003
+ if (typeof task.dispatchedSessionId === 'string' && task.dispatchedSessionId !== '') return task.dispatchedSessionId
2004
+ if (typeof task.sessionId === 'string' && task.sessionId !== '') return task.sessionId
2005
+ return pollFallbackSessionOf(task)
2006
+ }
2007
+
1363
2008
  /* ── 子组件 ───────────────────────────────────────────── */
1364
2009
 
1365
2010
  function Banner(props) {
@@ -1432,7 +2077,6 @@ window.__ModuleLoader__.load({
1432
2077
  const t = bind.t
1433
2078
  const busy = bind.busy
1434
2079
  const editing = bind.editing
1435
- const now = bind.now
1436
2080
  const actions = bind.actions
1437
2081
  const task = props.task
1438
2082
  const status = task.status
@@ -1473,7 +2117,7 @@ window.__ModuleLoader__.load({
1473
2117
  'div',
1474
2118
  { className: 'tb-edit-actions' },
1475
2119
  h('button', { type: 'button', className: 'tb-btn tb-btn-sm', onClick: () => actions.setEditing(null) }, t('card.cancel')),
1476
- h('button', { type: 'button', className: 'tb-btn tb-btn-sm tb-btn-primary', disabled: busy !== '', onClick: saveEdit }, t('card.save')),
2120
+ h('button', { type: 'button', className: 'tb-btn tb-btn-sm tb-btn-primary', disabled: busy !== '', onClick: () => actions.saveEdit() }, t('card.save')),
1477
2121
  ),
1478
2122
  ),
1479
2123
  )
@@ -1502,39 +2146,29 @@ window.__ModuleLoader__.load({
1502
2146
  cardActions.push([confirmingDelete ? 'deleteConfirmShort' : 'delete', requestDelete, false])
1503
2147
  }
1504
2148
 
1505
- const metaBits = [h('span', { key: 'id', className: 'tb-card-tag' }, task.id)]
1506
- if (task.source === 'agent') metaBits.push(h('span', { key: 'src', className: 'tb-card-tag' }, 'agent'))
1507
- if (task.cwd) {
1508
- metaBits.push(
1509
- h(
1510
- 'span',
1511
- { key: 'cwd', className: 'tb-card-tag', title: task.cwd },
1512
- t('card.workspace', { name: baseName(task.cwd) }),
1513
- ),
1514
- )
1515
- }
1516
- metaBits.push(h('span', { key: 'time' }, fmtAgo(t, task.updatedAt, now)))
1517
- if (task.notificationCount > 0 && status === 'todo') {
1518
- metaBits.push(h('span', { key: 'notified' }, t('card.notified', { n: task.notificationCount })))
1519
- }
1520
- if (task.assignee) metaBits.push(h('span', { key: 'assignee' }, t('card.assignee') + ': ' + task.assignee))
2149
+ // 卡片只留标题 + 操作按钮:note / result / lastError / id / 工作区 / 时间 /
2150
+ // 执行者 / 组长这些背景信息都在详情浮层里看(点标题或「详情」)。
2151
+ // 少这一整段后卡片高度由内容决定(.tb-card-fixed 的标题固定 2 行高度 +
2152
+ // 标题/按钮之间只留 gap,不再用整卡 min-height + 操作行 margin-top:auto 撑空行)。
1521
2153
 
1522
2154
  cardActions.unshift(['detail', () => actions.openDetail(task), false])
2155
+ // 卡片「对话」优先 worker 子会话(真正干活的对话),其次组长 / 发起对话;title 用实际目标 id 便于辨认。
1523
2156
  const cardSessionId = sessionOf(task)
1524
2157
  if (cardSessionId !== '') {
1525
- cardActions.push(['openChat', () => actions.openSession({ dispatchedSessionId: cardSessionId, sessionId: task.sessionId }), false])
2158
+ cardActions.push(['openChat', () => actions.openSession(cardSessionId), false, cardSessionId])
1526
2159
  }
1527
2160
 
1528
2161
  return h(
1529
2162
  'article',
1530
- { className: 'tb-card', style: { '--tb-accent': STATUS_ACCENT[status] } },
2163
+ { className: 'tb-card tb-card-fixed', style: { '--tb-accent': STATUS_ACCENT[status] } },
1531
2164
  h(
1532
2165
  'div',
1533
2166
  {
1534
2167
  className: 'tb-card-title tb-card-titlebtn',
1535
2168
  role: 'button',
1536
2169
  tabIndex: 0,
1537
- title: t('card.detail'),
2170
+ // 标题 2 行截断,title 属性兜住全文(鼠标悬停可看完整标题)
2171
+ title: task.title,
1538
2172
  onClick: () => actions.openDetail(task),
1539
2173
  onKeyDown: (event) => {
1540
2174
  if (event.key === 'Enter' || event.key === ' ') {
@@ -1545,12 +2179,6 @@ window.__ModuleLoader__.load({
1545
2179
  },
1546
2180
  task.title,
1547
2181
  ),
1548
- task.note
1549
- ? h('div', { className: 'tb-card-note', title: task.note }, task.note)
1550
- : null,
1551
- task.result ? h('div', { className: 'tb-card-result', title: task.result }, t('card.result') + ': ' + task.result) : null,
1552
- task.lastError ? h('div', { className: 'tb-card-error' }, task.lastError) : null,
1553
- h('div', { className: 'tb-card-meta' }, metaBits),
1554
2182
  h(
1555
2183
  'div',
1556
2184
  { className: 'tb-card-actions' },
@@ -1564,6 +2192,8 @@ window.__ModuleLoader__.load({
1564
2192
  'tb-btn tb-btn-sm' +
1565
2193
  (entry[2] ? ' tb-btn-primary' : '') +
1566
2194
  (entry[0] === 'delete' ? ' tb-btn-danger tb-btn-ghost' : ''),
2195
+ // 可选第 4 项:按钮 title(「对话」按钮用实际跳转的会话 id)。
2196
+ title: entry[3],
1567
2197
  disabled: busy === busyKey || busy === 'dispatch:' + task.id || busy === 'delete:' + task.id,
1568
2198
  onClick: entry[1],
1569
2199
  },
@@ -1580,11 +2210,16 @@ window.__ModuleLoader__.load({
1580
2210
  const t = bind.t
1581
2211
  const task = props.task
1582
2212
  if (!task) return null
2213
+ const richOptions = {
2214
+ attachment: (id) => (typeof bind.attachmentOf === 'function' ? bind.attachmentOf(id) : null),
2215
+ attachmentLoadingText: t('detail.imageLoading'),
2216
+ attachmentFailedText: t('detail.imageFailed'),
2217
+ }
1583
2218
  const metaRows = [
1584
2219
  [t('detail.workspace'), task.cwd || '—'],
2220
+ [t('detail.lead'), taskLeadLabel(task) || t('detail.noLead')],
1585
2221
  [t('detail.assignee'), task.assignee || t('detail.assigneeAuto')],
1586
2222
  [t('detail.source'), task.source === 'agent' ? t('detail.sourceAgent') : t('detail.sourceUser')],
1587
- [t('detail.notify'), String(task.notificationCount || 0)],
1588
2223
  [t('detail.id'), task.id],
1589
2224
  ]
1590
2225
  const timeRows = [
@@ -1595,6 +2230,21 @@ window.__ModuleLoader__.load({
1595
2230
  [t('detail.archived'), fmtShortWhen(task.archivedAt), fmtWhen(task.archivedAt)],
1596
2231
  ]
1597
2232
  const resultEmpty = task.status === 'done' && !task.result
2233
+ // 「关联对话」:发起(sessionId)/ 执行(worker assignee)/ 组长(dispatchedSessionId / poll 兜底),
2234
+ // 各自可点;同一个会话只显示一次(worker 可能等于发起会话,组长会话也可能等于发起会话)。
2235
+ const creatorSession = typeof task.sessionId === 'string' ? task.sessionId : ''
2236
+ const workerSession = workerSessionOf(task)
2237
+ const leadSession = leadSessionOf(task)
2238
+ const detailSessions = []
2239
+ if (creatorSession !== '') {
2240
+ detailSessions.push({ key: 'creator', label: t('detail.creatorSession'), sessionId: creatorSession })
2241
+ }
2242
+ if (workerSession !== '' && workerSession !== creatorSession) {
2243
+ detailSessions.push({ key: 'worker', label: t('detail.runSession'), sessionId: workerSession })
2244
+ }
2245
+ if (leadSession !== '' && leadSession !== workerSession && leadSession !== creatorSession) {
2246
+ detailSessions.push({ key: 'lead', label: t('detail.leadSession'), sessionId: leadSession })
2247
+ }
1598
2248
  const quick =
1599
2249
  task.status === 'todo'
1600
2250
  ? ['doing', t('card.start')]
@@ -1632,9 +2282,6 @@ window.__ModuleLoader__.load({
1632
2282
  { className: 'tb-detail-chip' },
1633
2283
  task.source === 'agent' ? t('detail.sourceAgent') : t('detail.sourceUser'),
1634
2284
  ),
1635
- task.notificationCount > 0
1636
- ? h('span', { className: 'tb-detail-chip' }, t('detail.notify') + ' ' + String(task.notificationCount))
1637
- : null,
1638
2285
  ),
1639
2286
  h('h2', { className: 'tb-detail-title' }, task.title),
1640
2287
  ),
@@ -1661,7 +2308,7 @@ window.__ModuleLoader__.load({
1661
2308
  'data-status': task.status,
1662
2309
  },
1663
2310
  task.result
1664
- ? renderRichText(task.result)
2311
+ ? renderRichText(task.result, richOptions)
1665
2312
  : task.status === 'done'
1666
2313
  ? t('detail.emptyResult')
1667
2314
  : t('detail.emptyResultPending'),
@@ -1674,7 +2321,7 @@ window.__ModuleLoader__.load({
1674
2321
  h(
1675
2322
  'div',
1676
2323
  { className: 'tb-detail-text tb-rich' + (task.note ? '' : ' tb-detail-muted') },
1677
- task.note ? renderRichText(task.note) : t('detail.emptyNote'),
2324
+ task.note ? renderRichText(task.note, richOptions) : t('detail.emptyNote'),
1678
2325
  ),
1679
2326
  ),
1680
2327
  h(
@@ -1697,33 +2344,21 @@ window.__ModuleLoader__.load({
1697
2344
  h(
1698
2345
  'div',
1699
2346
  { className: 'tb-detail-sessions' },
1700
- task.sessionId
1701
- ? h(
1702
- 'button',
1703
- {
1704
- type: 'button',
1705
- className: 'tb-btn tb-btn-sm',
1706
- title: task.sessionId,
1707
- onClick: () => props.openSession(task.sessionId),
1708
- },
1709
- t('detail.creatorSession') + ' · ' + shortSession(task.sessionId),
1710
- )
1711
- : null,
1712
- sessionOf(task) !== '' && sessionOf(task) !== task.sessionId
1713
- ? h(
1714
- 'button',
1715
- {
1716
- type: 'button',
1717
- className: 'tb-btn tb-btn-sm',
1718
- title: sessionOf(task),
1719
- onClick: () => props.openSession(sessionOf(task)),
1720
- },
1721
- t('detail.runSession') + ' · ' + shortSession(sessionOf(task)),
1722
- )
1723
- : null,
1724
- sessionOf(task) === ''
1725
- ? h('span', { className: 'tb-detail-muted' }, t('detail.noSession'))
1726
- : null,
2347
+ detailSessions.length === 0
2348
+ ? h('span', { className: 'tb-detail-muted' }, t('detail.noSession'))
2349
+ : detailSessions.map((entry) =>
2350
+ h(
2351
+ 'button',
2352
+ {
2353
+ key: entry.key,
2354
+ type: 'button',
2355
+ className: 'tb-btn tb-btn-sm',
2356
+ title: entry.sessionId,
2357
+ onClick: () => props.openSession(entry.sessionId),
2358
+ },
2359
+ entry.label + ' · ' + shortSession(entry.sessionId),
2360
+ ),
2361
+ ),
1727
2362
  ),
1728
2363
  ),
1729
2364
  ),
@@ -1773,7 +2408,157 @@ window.__ModuleLoader__.load({
1773
2408
  )
1774
2409
  }
1775
2410
 
1776
- return { Banner, Col, Detail }
2411
+ /**
2412
+ * 组长条(两块看板共用,v0.2.0):主会话绑定状态 + 当前看板涉及的工作区组长。
2413
+ * 数据来自 snapshot.leads(运行时视图:组长启停 / 忙闲变化不 bump revision,所以每次渲染都读最新快照);
2414
+ * 动作走 v0.2.0 RPC:bind-main-session / clear-main-session / ensure-workspace-lead。
2415
+ */
2416
+ function LeadBar() {
2417
+ const t = bind.t
2418
+ const busy = typeof bind.busy === 'string' ? bind.busy : ''
2419
+ const busyNow = busy !== ''
2420
+ const currentSessionId = typeof bind.currentSessionId === 'string' ? bind.currentSessionId : ''
2421
+ const leads = bind.leads && typeof bind.leads === 'object' ? bind.leads : null
2422
+ const main = leadMainRow(leads)
2423
+ const rows = Array.isArray(bind.leadRows) ? bind.leadRows : []
2424
+ const actions = bind.leadActions || {}
2425
+ const bindHint = currentSessionId === '' ? t('lead.noCurrentSession') : t('lead.bind')
2426
+ const dot = (status) =>
2427
+ h('span', { key: 'dot', className: 'tb-lead-dot', 'data-status': status, 'aria-hidden': 'true' })
2428
+ const stateText = (status) =>
2429
+ h('span', { key: 'state', className: 'tb-lead-state' }, t('lead.status.' + status))
2430
+ const bindButton = (labelKey, key) =>
2431
+ h(
2432
+ 'button',
2433
+ {
2434
+ key,
2435
+ type: 'button',
2436
+ className: 'tb-btn tb-btn-sm tb-btn-ghost tb-lead-btn',
2437
+ disabled: busyNow || currentSessionId === '',
2438
+ title: bindHint,
2439
+ onClick: () => {
2440
+ if (typeof actions.bindMain === 'function') actions.bindMain()
2441
+ },
2442
+ },
2443
+ t(labelKey),
2444
+ )
2445
+
2446
+ const mainBits = []
2447
+ if (main) {
2448
+ mainBits.push(dot(main.status))
2449
+ mainBits.push(
2450
+ h(
2451
+ 'span',
2452
+ { key: 'label', className: 'tb-lead-label', title: main.title || main.sessionId },
2453
+ t('lead.mainLabel', { title: leadTitleTail(main.title, t('lead.mainFallback')) }),
2454
+ ),
2455
+ )
2456
+ mainBits.push(stateText(main.status))
2457
+ mainBits.push(
2458
+ h(
2459
+ 'button',
2460
+ {
2461
+ key: 'open',
2462
+ type: 'button',
2463
+ className: 'tb-btn tb-btn-sm tb-btn-ghost tb-lead-btn',
2464
+ title: main.sessionId,
2465
+ onClick: () => {
2466
+ if (typeof actions.openSession === 'function') actions.openSession(main.sessionId)
2467
+ },
2468
+ },
2469
+ t('lead.open'),
2470
+ ),
2471
+ )
2472
+ mainBits.push(bindButton('lead.rebind', 'rebind'))
2473
+ mainBits.push(
2474
+ h(
2475
+ 'button',
2476
+ {
2477
+ key: 'clear',
2478
+ type: 'button',
2479
+ className: 'tb-btn tb-btn-sm tb-btn-ghost tb-lead-btn',
2480
+ disabled: busyNow,
2481
+ onClick: () => {
2482
+ if (typeof actions.clearMain === 'function') actions.clearMain()
2483
+ },
2484
+ },
2485
+ t('lead.clear'),
2486
+ ),
2487
+ )
2488
+ } else {
2489
+ mainBits.push(dot('missing'))
2490
+ mainBits.push(h('span', { key: 'label', className: 'tb-lead-label' }, t('lead.unbound')))
2491
+ mainBits.push(bindButton('lead.bind', 'bind'))
2492
+ if (currentSessionId === '') {
2493
+ mainBits.push(h('span', { key: 'hint', className: 'tb-lead-hint' }, t('lead.noCurrentSession')))
2494
+ }
2495
+ }
2496
+
2497
+ const cells = [
2498
+ h(
2499
+ 'div',
2500
+ {
2501
+ key: 'main',
2502
+ className: 'tb-lead tb-lead-main',
2503
+ 'data-status': main ? main.status : 'missing',
2504
+ title: main ? main.title || main.sessionId : '',
2505
+ },
2506
+ mainBits,
2507
+ ),
2508
+ ]
2509
+ rows.forEach((row) => {
2510
+ const bits = [
2511
+ dot(row.status),
2512
+ h(
2513
+ 'span',
2514
+ { key: 'label', className: 'tb-lead-label', title: row.cwd || row.sessionId || '' },
2515
+ t('lead.wsLabel', { label: row.label || t('lead.wsFallback') }),
2516
+ ),
2517
+ stateText(row.status),
2518
+ ]
2519
+ if (row.missing || row.status === 'archived') {
2520
+ bits.push(
2521
+ h(
2522
+ 'button',
2523
+ {
2524
+ key: 'create',
2525
+ type: 'button',
2526
+ className: 'tb-btn tb-btn-sm tb-btn-ghost tb-lead-btn',
2527
+ disabled: busyNow || row.cwd === '',
2528
+ title: row.cwd,
2529
+ onClick: () => {
2530
+ if (typeof actions.ensureLead === 'function') actions.ensureLead(row.cwd)
2531
+ },
2532
+ },
2533
+ t('lead.create'),
2534
+ ),
2535
+ )
2536
+ } else {
2537
+ bits.push(
2538
+ h(
2539
+ 'button',
2540
+ {
2541
+ key: 'open',
2542
+ type: 'button',
2543
+ className: 'tb-btn tb-btn-sm tb-btn-ghost tb-lead-btn',
2544
+ disabled: row.sessionId === '',
2545
+ title: row.sessionId,
2546
+ onClick: () => {
2547
+ if (typeof actions.openSession === 'function') actions.openSession(row.sessionId)
2548
+ },
2549
+ },
2550
+ t('lead.open'),
2551
+ ),
2552
+ )
2553
+ }
2554
+ cells.push(
2555
+ h('div', { key: 'ws:' + row.key, className: 'tb-lead tb-lead-ws', 'data-status': row.status }, bits),
2556
+ )
2557
+ })
2558
+ return h('div', { className: 'tb-leads', role: 'group', 'aria-label': t('lead.barLabel') }, cells)
2559
+ }
2560
+
2561
+ return { Banner, Col, Detail, LeadBar }
1777
2562
  }
1778
2563
 
1779
2564
  /* ── 看板页 ─────────────────────────────────────────────── */
@@ -1785,7 +2570,9 @@ window.__ModuleLoader__.load({
1785
2570
  function BoardTab(props) {
1786
2571
  const useTabInfo = props ? props.useTabInfo : undefined
1787
2572
  // 右栏 tab 是 session scope,宿主会传当前会话 id:任务记下它,派发时回到这个对话。
2573
+ // 同一个 id 也是「把当前对话设为主会话」(bind-main-session)的入参。
1788
2574
  const sessionId = props && typeof props.sessionId === 'string' ? props.sessionId : ''
2575
+ if (sessionId !== '') lastConversationSessionId = sessionId
1789
2576
  const tabInfo = (() => {
1790
2577
  if (typeof useTabInfo !== 'function') return null
1791
2578
  try {
@@ -1806,10 +2593,15 @@ window.__ModuleLoader__.load({
1806
2593
  const boardBindRef = useRef(null)
1807
2594
  const boardPiecesRef = useRef(null)
1808
2595
  const [notice, setNotice] = useState(null)
1809
- const [now, setNow] = useState(Date.now())
1810
2596
  const [title, setTitle] = useState('')
1811
2597
  const [note, setNote] = useState('')
1812
2598
  const [showNote, setShowNote] = useState(false)
2599
+ // v0.2.0:待提交的粘贴图片({id, preview, ...})与详情浮层的附件 data URL 缓存。
2600
+ const [attachments, setAttachments] = useState([])
2601
+ // 上传中的请求计数(不是布尔):连续多次粘贴时,只有全部结束才解除提交禁用。
2602
+ const [uploadingCount, setUploadingCount] = useState(0)
2603
+ const [attachmentSources, setAttachmentSources] = useState({})
2604
+ const attachmentSourcesRef = useRef({})
1813
2605
  const [editing, setEditing] = useState(null)
1814
2606
  const aliveRef = useRef(true)
1815
2607
 
@@ -1875,12 +2667,6 @@ window.__ModuleLoader__.load({
1875
2667
  return () => stop()
1876
2668
  }, [refresh])
1877
2669
 
1878
- // 相对时间每分钟重算一次。
1879
- useEffect(() => {
1880
- const stop = every(() => setNow(Date.now()), 30000)
1881
- return () => stop()
1882
- }, [])
1883
-
1884
2670
  const config = (snap && snap.config) || { pollEnabled: true, pollIntervalMs: 15000 }
1885
2671
  const allTasks = (snap && snap.tasks) || []
1886
2672
  const poll = (snap && snap.poll) || {}
@@ -1916,6 +2702,10 @@ window.__ModuleLoader__.load({
1916
2702
  ).length
1917
2703
  const groups = groupTasks(tasks)
1918
2704
  const preset = (snap && snap.preset) || null
2705
+ // v0.2.0 组长条:leads 是运行时视图(组长启停 / 忙闲不 bump revision),每次渲染都读最新值;
2706
+ // 右栏只列当前看板可见任务涉及的工作区,没组长的补「创建组长」入口。
2707
+ const leads = (snap && snap.leads) || null
2708
+ const leadRows = workspaceLeadRows(leads, taskWorkspaceCwds(tasks, cwdForHint), { all: false })
1919
2709
 
1920
2710
  /** 统一执行一次写操作:忙态 + 错误提示 + 成功后刷新。 */
1921
2711
  const run = useCallback(
@@ -1938,11 +2728,19 @@ window.__ModuleLoader__.load({
1938
2728
  )
1939
2729
 
1940
2730
  function submitTask() {
2731
+ // 上传中(计数 > 0)不提交:Enter 与按钮共用同一闸门,避免 note 里只有一半附件引用。
2732
+ if (isUploading(uploadingCount)) return
1941
2733
  const trimmedTitle = title.trim()
1942
2734
  if (trimmedTitle === '') {
1943
2735
  setNotice({ tone: 'warn', text: t('composer.empty') })
1944
2736
  return
1945
2737
  }
2738
+ // 客户端预检:note 里不同附件引用 > 8 时给具体提示(与服务端 bad-request 文案同源,§2.1)。
2739
+ const limitText = noteAttachmentLimitText(t, note)
2740
+ if (limitText !== '') {
2741
+ setNotice({ tone: 'error', text: limitText })
2742
+ return
2743
+ }
1946
2744
  const payload = { title: trimmedTitle }
1947
2745
  if (note.trim() !== '') payload.note = note.trim()
1948
2746
  if (sessionId !== '') payload.sessionId = sessionId
@@ -1951,6 +2749,7 @@ window.__ModuleLoader__.load({
1951
2749
  setTitle('')
1952
2750
  setNote('')
1953
2751
  setShowNote(false)
2752
+ setAttachments([])
1954
2753
  })
1955
2754
  }
1956
2755
 
@@ -2006,10 +2805,50 @@ window.__ModuleLoader__.load({
2006
2805
  setNotice({ tone: 'warn', text: t('composer.empty') })
2007
2806
  return
2008
2807
  }
2808
+ // 编辑备注同样受单任务 8 个附件引用的限制(文本里手写的引用也算)。
2809
+ const limitText = noteAttachmentLimitText(t, editing.note)
2810
+ if (limitText !== '') {
2811
+ setNotice({ tone: 'error', text: limitText })
2812
+ return
2813
+ }
2009
2814
  updateTask(editing.id, { title: trimmedTitle, note: String(editing.note || '').trim() })
2010
2815
  setEditing(null)
2011
2816
  }
2012
2817
 
2818
+ /** 备注粘贴:有图片就走上传 + 短引用;没有图片返回 false(保持默认文本粘贴)。 */
2819
+ function onNotePaste(event) {
2820
+ return handleNotePaste(event, {
2821
+ t,
2822
+ setNote,
2823
+ setPending: setAttachments,
2824
+ beginUpload: () => setUploadingCount((value) => value + 1),
2825
+ endUpload: () => setUploadingCount((value) => Math.max(0, value - 1)),
2826
+ setNotice,
2827
+ })
2828
+ }
2829
+
2830
+ /** 移除一张待提交图片:缩略图与 note 里的引用一起删。 */
2831
+ function removePendingAttachment(id) {
2832
+ setAttachments((prev) => prev.filter((item) => item.id !== id))
2833
+ setNote((prev) => removeAttachmentRef(prev, id))
2834
+ }
2835
+
2836
+ /* ── 组长条动作(v0.2.0)────────────────────────────────── */
2837
+ // 三个新 RPC:bind-main-session {sessionId} / clear-main-session {} / ensure-workspace-lead {cwd}。
2838
+ // 失败走 run() 的顶部错误条(errorText),不乐观更新、不崩。
2839
+ const leadActions = {
2840
+ bindMain: () => {
2841
+ if (sessionId === '') return
2842
+ run('lead:bind', () => callRpc('bind-main-session', { sessionId }), t('lead.bindOk'))
2843
+ },
2844
+ clearMain: () => run('lead:clear', () => callRpc('clear-main-session', {}), t('lead.clearOk')),
2845
+ ensureLead: (cwd) => {
2846
+ if (typeof cwd !== 'string' || cwd === '') return
2847
+ run('lead:ensure', () => callRpc('ensure-workspace-lead', { cwd }), t('lead.ensureOk'))
2848
+ },
2849
+ openSession: (sessionIdToOpen) => openSessionById(sessionIdToOpen),
2850
+ }
2851
+
2013
2852
  /* ── 子组件(与平台看板共用)──────────────────────────── */
2014
2853
  // 组件身份保持稳定:bind 存在 ref 里,每次渲染只更新字段;pieces 只创建一次。
2015
2854
  // 否则轮询每 2s 刷新都会换掉组件类型 → React 卸载重建 → 详情浮层闪一下、滚动位置丢。
@@ -2019,8 +2858,18 @@ window.__ModuleLoader__.load({
2019
2858
  removeTask,
2020
2859
  requestDelete,
2021
2860
  isConfirmingDelete: (id) => confirmDeleteId === id,
2022
- openDetail: (task) => setDetailId(task.id),
2023
- openSession: (task) => openSessionById(task && (task.dispatchedSessionId || task.sessionId)),
2861
+ openDetail: (task) => {
2862
+ if (task) loadTaskAttachments(task, attachmentSourcesRef, setAttachmentSources)
2863
+ setDetailId(task.id)
2864
+ },
2865
+ // 「对话」按钮传目标会话 id;仍兼容传任务对象的旧调用(取 dispatched → creator)。
2866
+ openSession: (target) => {
2867
+ if (typeof target === 'string') {
2868
+ openSessionById(target)
2869
+ return
2870
+ }
2871
+ openSessionById(target && (target.dispatchedSessionId || target.sessionId))
2872
+ },
2024
2873
  startEdit,
2025
2874
  saveEdit,
2026
2875
  setEditing,
@@ -2031,23 +2880,32 @@ window.__ModuleLoader__.load({
2031
2880
  t,
2032
2881
  busy: '',
2033
2882
  editing: null,
2034
- now: 0,
2035
2883
  actions: boardActions,
2036
2884
  fallbackDispatchSessionId: '',
2037
2885
  lastDispatchTaskId: '',
2886
+ leads: null,
2887
+ leadRows: [],
2888
+ currentSessionId: '',
2889
+ leadActions,
2038
2890
  }
2039
2891
  }
2040
2892
  boardBindRef.current.t = t
2041
2893
  boardBindRef.current.busy = busy
2042
2894
  boardBindRef.current.editing = editing
2043
- boardBindRef.current.now = now
2044
2895
  boardBindRef.current.actions = boardActions
2896
+ boardBindRef.current.attachmentOf = (id) => attachmentSources[id] || null
2045
2897
  boardBindRef.current.fallbackDispatchSessionId = fallbackDispatchSessionId
2046
2898
  boardBindRef.current.lastDispatchTaskId = (poll && poll.lastDispatchTaskId) || ''
2899
+ // 组长条字段每次都刷新:leads 是运行时视图,revision 不变也会变。
2900
+ boardBindRef.current.leads = leads
2901
+ boardBindRef.current.leadRows = leadRows
2902
+ boardBindRef.current.currentSessionId = sessionId
2903
+ boardBindRef.current.leadActions = leadActions
2047
2904
  if (boardPiecesRef.current === null) boardPiecesRef.current = createBoardPieces(boardBindRef.current)
2048
2905
  const Banner = boardPiecesRef.current.Banner
2049
2906
  const Col = boardPiecesRef.current.Col
2050
2907
  const Detail = boardPiecesRef.current.Detail
2908
+ const LeadBar = boardPiecesRef.current.LeadBar
2051
2909
 
2052
2910
  /* ── 顶部状态文案 ─────────────────────────────────────── */
2053
2911
 
@@ -2132,13 +2990,13 @@ window.__ModuleLoader__.load({
2132
2990
  'select',
2133
2991
  {
2134
2992
  className: 'tb-select',
2135
- value: config.dispatchMode || 'new',
2993
+ value: dispatchModeOf(config),
2136
2994
  disabled: busyNow,
2137
2995
  title: t('dispatch.modeHint'),
2138
2996
  'aria-label': t('dispatch.mode'),
2139
2997
  onChange: (event) => setConfig({ dispatchMode: event.target.value }),
2140
2998
  },
2141
- ['new', 'creator', 'auto'].map((mode) => h('option', { key: mode, value: mode }, t('dispatch.mode.' + mode))),
2999
+ DISPATCH_MODES.map((mode) => h('option', { key: mode, value: mode }, t('dispatch.mode.' + mode))),
2142
3000
  ),
2143
3001
  ),
2144
3002
  h(
@@ -2159,6 +3017,7 @@ window.__ModuleLoader__.load({
2159
3017
  ),
2160
3018
  ),
2161
3019
 
3020
+ h(LeadBar, { key: 'leads' }),
2162
3021
  presetBanner ? h(Banner, { item: presetBanner }) : null,
2163
3022
  notice ? h(Banner, { item: notice, onClose: () => setNotice(null) }) : null,
2164
3023
  failures > 0 && error
@@ -2199,7 +3058,7 @@ window.__ModuleLoader__.load({
2199
3058
  {
2200
3059
  type: 'button',
2201
3060
  className: 'tb-btn tb-btn-primary',
2202
- disabled: busyNow || title.trim() === '',
3061
+ disabled: submitBlocked({ busy: busyNow, uploading: uploadingCount, title }),
2203
3062
  onClick: submitTask,
2204
3063
  },
2205
3064
  t('composer.submit'),
@@ -2211,8 +3070,38 @@ window.__ModuleLoader__.load({
2211
3070
  placeholder: t('composer.note'),
2212
3071
  value: note,
2213
3072
  onChange: (event) => setNote(event.target.value),
3073
+ onPaste: onNotePaste,
2214
3074
  })
2215
3075
  : null,
3076
+ attachments.length > 0
3077
+ ? h(
3078
+ 'div',
3079
+ { className: 'tb-attach-strip' },
3080
+ attachments.map((item) =>
3081
+ h(
3082
+ 'div',
3083
+ { key: item.id, className: 'tb-attach-item' },
3084
+ h('img', {
3085
+ className: 'tb-attach-thumb',
3086
+ src: item.preview,
3087
+ alt: typeof item.name === 'string' ? item.name : '',
3088
+ title: t('composer.removeImage'),
3089
+ }),
3090
+ h(
3091
+ 'button',
3092
+ {
3093
+ type: 'button',
3094
+ className: 'tb-attach-remove',
3095
+ onClick: () => removePendingAttachment(item.id),
3096
+ 'aria-label': t('composer.removeImage'),
3097
+ title: t('composer.removeImage'),
3098
+ },
3099
+ '\u00d7',
3100
+ ),
3101
+ ),
3102
+ ),
3103
+ )
3104
+ : null,
2216
3105
  h(
2217
3106
  'div',
2218
3107
  { className: 'tb-composer-meta' },
@@ -2221,6 +3110,7 @@ window.__ModuleLoader__.load({
2221
3110
  { type: 'button', className: 'tb-linkbtn', onClick: () => setShowNote(!showNote), 'aria-expanded': showNote ? 'true' : 'false' },
2222
3111
  showNote ? t('composer.hideNote') : t('composer.addNote'),
2223
3112
  ),
3113
+ isUploading(uploadingCount) ? h('span', { className: 'tb-hint' }, t('composer.uploading')) : null,
2224
3114
  h(
2225
3115
  'span',
2226
3116
  { className: 'tb-hint' },
@@ -2317,10 +3207,15 @@ window.__ModuleLoader__.load({
2317
3207
  const boardBindRef = useRef(null)
2318
3208
  const boardPiecesRef = useRef(null)
2319
3209
  const [notice, setNotice] = useState(null)
2320
- const [now, setNow] = useState(Date.now())
2321
3210
  const [title, setTitle] = useState('')
2322
3211
  const [note, setNote] = useState('')
2323
3212
  const [showNote, setShowNote] = useState(false)
3213
+ // v0.2.0:与右栏看板同一套粘贴图片 / 详情附件缓存。
3214
+ const [attachments, setAttachments] = useState([])
3215
+ // 上传中的请求计数(不是布尔):连续多次粘贴时,只有全部结束才解除提交禁用。
3216
+ const [uploadingCount, setUploadingCount] = useState(0)
3217
+ const [attachmentSources, setAttachmentSources] = useState({})
3218
+ const attachmentSourcesRef = useRef({})
2324
3219
  const [editing, setEditing] = useState(null)
2325
3220
  const [filterPath, setFilterPath] = useState('')
2326
3221
  const [workspaceCwd, setWorkspaceCwd] = useState('')
@@ -2365,12 +3260,6 @@ window.__ModuleLoader__.load({
2365
3260
  return () => stop()
2366
3261
  }, [refresh])
2367
3262
 
2368
- // 相对时间每分钟重算一次。
2369
- useEffect(() => {
2370
- const stop = every(() => setNow(Date.now()), 30000)
2371
- return () => stop()
2372
- }, [])
2373
-
2374
3263
  const config = (snap && snap.config) || { pollEnabled: true, pollIntervalMs: 15000 }
2375
3264
  const allTasks = (snap && snap.tasks) || []
2376
3265
  const workspaces = (snap && snap.workspaces) || []
@@ -2394,6 +3283,11 @@ window.__ModuleLoader__.load({
2394
3283
  const fallbackDispatchSessionId =
2395
3284
  poll && poll.lastDispatchSessionId && (poll.lastDispatchTaskId || doingAll.length === 1) ? poll.lastDispatchSessionId : ''
2396
3285
  const detailTask = detailId ? allTasks.find((task) => task && task.id === detailId) || null : null
3286
+ // v0.2.0 组长条:完整看板列出全部工作区组长(leads 是运行时视图,每次渲染都读最新值)。
3287
+ // 根作用域的 main 页拿不到 session 绑定:用最近渲染过的对话 id 当「当前对话」,没有就禁用绑定按钮。
3288
+ const leads = (snap && snap.leads) || null
3289
+ const leadRows = workspaceLeadRows(leads, [], { all: true })
3290
+ const currentSessionId = lastConversationSessionId
2397
3291
 
2398
3292
  /** 统一执行一次写操作:忙态 + 错误提示 + 成功后刷新。 */
2399
3293
  const run = useCallback(
@@ -2416,6 +3310,8 @@ window.__ModuleLoader__.load({
2416
3310
  )
2417
3311
 
2418
3312
  function submitTask() {
3313
+ // 上传中(计数 > 0)不提交:Enter 与按钮共用同一闸门,避免 note 里只有一半附件引用。
3314
+ if (isUploading(uploadingCount)) return
2419
3315
  const trimmedTitle = title.trim()
2420
3316
  if (trimmedTitle === '') {
2421
3317
  setNotice({ tone: 'warn', text: t('composer.empty') })
@@ -2425,6 +3321,12 @@ window.__ModuleLoader__.load({
2425
3321
  setNotice({ tone: 'warn', text: t('platform.workspaceRequired') })
2426
3322
  return
2427
3323
  }
3324
+ // 客户端预检:note 里不同附件引用 > 8 时给具体提示(与服务端 bad-request 文案同源,§2.1)。
3325
+ const limitText = noteAttachmentLimitText(t, note)
3326
+ if (limitText !== '') {
3327
+ setNotice({ tone: 'error', text: limitText })
3328
+ return
3329
+ }
2428
3330
  // 平台看板不绑会话:任务归属由所选工作区决定(cwd),派发由宿主自动挑会话。
2429
3331
  const payload = { title: trimmedTitle, cwd: workspaceCwd }
2430
3332
  if (note.trim() !== '') payload.note = note.trim()
@@ -2433,6 +3335,7 @@ window.__ModuleLoader__.load({
2433
3335
  setTitle('')
2434
3336
  setNote('')
2435
3337
  setShowNote(false)
3338
+ setAttachments([])
2436
3339
  })
2437
3340
  }
2438
3341
 
@@ -2488,10 +3391,48 @@ window.__ModuleLoader__.load({
2488
3391
  setNotice({ tone: 'warn', text: t('composer.empty') })
2489
3392
  return
2490
3393
  }
3394
+ // 编辑备注同样受单任务 8 个附件引用的限制(文本里手写的引用也算)。
3395
+ const limitText = noteAttachmentLimitText(t, editing.note)
3396
+ if (limitText !== '') {
3397
+ setNotice({ tone: 'error', text: limitText })
3398
+ return
3399
+ }
2491
3400
  updateTask(editing.id, { title: trimmedTitle, note: String(editing.note || '').trim() })
2492
3401
  setEditing(null)
2493
3402
  }
2494
3403
 
3404
+ /** 备注粘贴:有图片就走上传 + 短引用;没有图片返回 false(保持默认文本粘贴)。 */
3405
+ function onNotePaste(event) {
3406
+ return handleNotePaste(event, {
3407
+ t,
3408
+ setNote,
3409
+ setPending: setAttachments,
3410
+ beginUpload: () => setUploadingCount((value) => value + 1),
3411
+ endUpload: () => setUploadingCount((value) => Math.max(0, value - 1)),
3412
+ setNotice,
3413
+ })
3414
+ }
3415
+
3416
+ /** 移除一张待提交图片:缩略图与 note 里的引用一起删。 */
3417
+ function removePendingAttachment(id) {
3418
+ setAttachments((prev) => prev.filter((item) => item.id !== id))
3419
+ setNote((prev) => removeAttachmentRef(prev, id))
3420
+ }
3421
+
3422
+ /* ── 组长条动作(v0.2.0,与右栏看板同一套 RPC)──────────── */
3423
+ const leadActions = {
3424
+ bindMain: () => {
3425
+ if (currentSessionId === '') return
3426
+ run('lead:bind', () => callRpc('bind-main-session', { sessionId: currentSessionId }), t('lead.bindOk'))
3427
+ },
3428
+ clearMain: () => run('lead:clear', () => callRpc('clear-main-session', {}), t('lead.clearOk')),
3429
+ ensureLead: (cwd) => {
3430
+ if (typeof cwd !== 'string' || cwd === '') return
3431
+ run('lead:ensure', () => callRpc('ensure-workspace-lead', { cwd }), t('lead.ensureOk'))
3432
+ },
3433
+ openSession: (sessionIdToOpen) => openSessionById(sessionIdToOpen),
3434
+ }
3435
+
2495
3436
  // 组件身份保持稳定(同右栏看板):bind 存 ref、只改字段,pieces 只创建一次。
2496
3437
  const boardActions = {
2497
3438
  updateTask,
@@ -2499,8 +3440,18 @@ window.__ModuleLoader__.load({
2499
3440
  removeTask,
2500
3441
  requestDelete,
2501
3442
  isConfirmingDelete: (id) => confirmDeleteId === id,
2502
- openDetail: (task) => setDetailId(task.id),
2503
- openSession: (task) => openSessionById(task && (task.dispatchedSessionId || task.sessionId)),
3443
+ openDetail: (task) => {
3444
+ if (task) loadTaskAttachments(task, attachmentSourcesRef, setAttachmentSources)
3445
+ setDetailId(task.id)
3446
+ },
3447
+ // 「对话」按钮传目标会话 id;仍兼容传任务对象的旧调用(取 dispatched → creator)。
3448
+ openSession: (target) => {
3449
+ if (typeof target === 'string') {
3450
+ openSessionById(target)
3451
+ return
3452
+ }
3453
+ openSessionById(target && (target.dispatchedSessionId || target.sessionId))
3454
+ },
2504
3455
  startEdit,
2505
3456
  saveEdit,
2506
3457
  setEditing,
@@ -2511,23 +3462,32 @@ window.__ModuleLoader__.load({
2511
3462
  t,
2512
3463
  busy: '',
2513
3464
  editing: null,
2514
- now: 0,
2515
3465
  actions: boardActions,
2516
3466
  fallbackDispatchSessionId: '',
2517
3467
  lastDispatchTaskId: '',
3468
+ leads: null,
3469
+ leadRows: [],
3470
+ currentSessionId: '',
3471
+ leadActions,
2518
3472
  }
2519
3473
  }
2520
3474
  boardBindRef.current.t = t
2521
3475
  boardBindRef.current.busy = busy
2522
3476
  boardBindRef.current.editing = editing
2523
- boardBindRef.current.now = now
2524
3477
  boardBindRef.current.actions = boardActions
3478
+ boardBindRef.current.attachmentOf = (id) => attachmentSources[id] || null
2525
3479
  boardBindRef.current.fallbackDispatchSessionId = fallbackDispatchSessionId
2526
3480
  boardBindRef.current.lastDispatchTaskId = (poll && poll.lastDispatchTaskId) || ''
3481
+ // 组长条字段每次都刷新:leads 是运行时视图,revision 不变也会变。
3482
+ boardBindRef.current.leads = leads
3483
+ boardBindRef.current.leadRows = leadRows
3484
+ boardBindRef.current.currentSessionId = currentSessionId
3485
+ boardBindRef.current.leadActions = leadActions
2527
3486
  if (boardPiecesRef.current === null) boardPiecesRef.current = createBoardPieces(boardBindRef.current)
2528
3487
  const Banner = boardPiecesRef.current.Banner
2529
3488
  const Col = boardPiecesRef.current.Col
2530
3489
  const Detail = boardPiecesRef.current.Detail
3490
+ const LeadBar = boardPiecesRef.current.LeadBar
2531
3491
 
2532
3492
  const intervalText = fmtInterval(config.pollIntervalMs)
2533
3493
  const busyNow = busy !== ''
@@ -2591,13 +3551,13 @@ window.__ModuleLoader__.load({
2591
3551
  'select',
2592
3552
  {
2593
3553
  className: 'tb-select',
2594
- value: config.dispatchMode || 'new',
3554
+ value: dispatchModeOf(config),
2595
3555
  disabled: busyNow,
2596
3556
  title: t('dispatch.modeHint'),
2597
3557
  'aria-label': t('dispatch.mode'),
2598
3558
  onChange: (event) => setConfig({ dispatchMode: event.target.value }),
2599
3559
  },
2600
- ['new', 'creator', 'auto'].map((mode) => h('option', { key: mode, value: mode }, t('dispatch.mode.' + mode))),
3560
+ DISPATCH_MODES.map((mode) => h('option', { key: mode, value: mode }, t('dispatch.mode.' + mode))),
2601
3561
  ),
2602
3562
  ),
2603
3563
  h(
@@ -2623,6 +3583,7 @@ window.__ModuleLoader__.load({
2623
3583
  ),
2624
3584
  ),
2625
3585
 
3586
+ h(LeadBar, { key: 'leads' }),
2626
3587
  presetBanner ? h(Banner, { item: presetBanner }) : null,
2627
3588
  notice ? h(Banner, { item: notice, onClose: () => setNotice(null) }) : null,
2628
3589
  failures > 0 && error
@@ -2672,7 +3633,7 @@ window.__ModuleLoader__.load({
2672
3633
  {
2673
3634
  type: 'button',
2674
3635
  className: 'tb-btn tb-btn-primary',
2675
- disabled: busyNow || title.trim() === '' || workspaceRequired,
3636
+ disabled: submitBlocked({ busy: busyNow, uploading: uploadingCount, title, workspaceRequired }),
2676
3637
  onClick: submitTask,
2677
3638
  },
2678
3639
  t('composer.submit'),
@@ -2684,8 +3645,38 @@ window.__ModuleLoader__.load({
2684
3645
  placeholder: t('composer.note'),
2685
3646
  value: note,
2686
3647
  onChange: (event) => setNote(event.target.value),
3648
+ onPaste: onNotePaste,
2687
3649
  })
2688
3650
  : null,
3651
+ attachments.length > 0
3652
+ ? h(
3653
+ 'div',
3654
+ { className: 'tb-attach-strip' },
3655
+ attachments.map((item) =>
3656
+ h(
3657
+ 'div',
3658
+ { key: item.id, className: 'tb-attach-item' },
3659
+ h('img', {
3660
+ className: 'tb-attach-thumb',
3661
+ src: item.preview,
3662
+ alt: typeof item.name === 'string' ? item.name : '',
3663
+ title: t('composer.removeImage'),
3664
+ }),
3665
+ h(
3666
+ 'button',
3667
+ {
3668
+ type: 'button',
3669
+ className: 'tb-attach-remove',
3670
+ onClick: () => removePendingAttachment(item.id),
3671
+ 'aria-label': t('composer.removeImage'),
3672
+ title: t('composer.removeImage'),
3673
+ },
3674
+ '\u00d7',
3675
+ ),
3676
+ ),
3677
+ ),
3678
+ )
3679
+ : null,
2689
3680
  h(
2690
3681
  'div',
2691
3682
  { className: 'tb-composer-meta' },
@@ -2694,6 +3685,7 @@ window.__ModuleLoader__.load({
2694
3685
  { type: 'button', className: 'tb-linkbtn', onClick: () => setShowNote(!showNote), 'aria-expanded': showNote ? 'true' : 'false' },
2695
3686
  showNote ? t('composer.hideNote') : t('composer.addNote'),
2696
3687
  ),
3688
+ isUploading(uploadingCount) ? h('span', { className: 'tb-hint' }, t('composer.uploading')) : null,
2697
3689
  workspaceRequired ? h('span', { className: 'tb-hint' }, t('platform.workspaceRequired')) : null,
2698
3690
  ),
2699
3691
  ),
@@ -2863,6 +3855,9 @@ window.__ModuleLoader__.load({
2863
3855
  fmtClock,
2864
3856
  fmtInterval,
2865
3857
  shortSession,
3858
+ // v0.2.0 任务关联对话:worker 会话判定(assignee 只在能提取到会话 id 时算会话)
3859
+ workerSessionOf,
3860
+ extractSessionId,
2866
3861
  groupTasks,
2867
3862
  statusAccent: STATUS_ACCENT,
2868
3863
  statusOrder: STATUS_ORDER,
@@ -2875,6 +3870,30 @@ window.__ModuleLoader__.load({
2875
3870
  parseRichText,
2876
3871
  splitLooseSegments,
2877
3872
  renderInline,
3873
+ // v0.2.0 粘贴图片附件纯函数
3874
+ attachmentRef,
3875
+ attachmentIdsIn,
3876
+ insertAttachmentRef,
3877
+ removeAttachmentRef,
3878
+ clipboardImageFiles,
3879
+ splitPasteImages,
3880
+ isUploading,
3881
+ submitBlocked,
3882
+ noteAttachmentLimitText,
3883
+ maxPasteImages: MAX_PASTE_IMAGES,
3884
+ maxAttachmentBytes: MAX_ATTACHMENT_BYTES,
3885
+ maxAttachmentMb: MAX_ATTACHMENT_MB,
3886
+ maxAttachmentCache: MAX_ATTACHMENT_CACHE,
3887
+ maxNoteAttachments: MAX_NOTE_ATTACHMENTS,
3888
+ // v0.2.0 组长条 / 派发模式纯展示函数
3889
+ dispatchModes: DISPATCH_MODES,
3890
+ dispatchModeOf,
3891
+ leadStatusKey,
3892
+ leadTitleTail,
3893
+ leadMainRow,
3894
+ taskLeadLabel,
3895
+ taskWorkspaceCwds,
3896
+ workspaceLeadRows,
2878
3897
  }
2879
3898
 
2880
3899
  return module.exports