dsh-dispatch-board 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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,13 +97,18 @@ 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
114
  '.tb-colhead{display:flex;align-items:center;gap:7px;padding:1px 1px 5px;border-bottom:1px solid var(--dsw-alias-border-l1)}',
@@ -109,13 +120,10 @@ window.__ModuleLoader__.load({
109
120
  '.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
121
 
111
122
  // ── 卡片 ───────────────────────────────────────────────────
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}',
123
+ // 卡片正文只有标题 + 操作按钮:note / result / lastError / meta 全部收进详情浮层,
124
+ // 看板上只靠标题辨认任务(完整信息点标题看详情)。
125
+ '.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
126
  '.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
127
  '.tb-card-actions{display:flex;align-items:center;gap:4px;flex-wrap:wrap;padding-top:2px}',
120
128
  '.tb-edit{display:flex;flex-direction:column;gap:6px}',
121
129
  '.tb-edit-actions{display:flex;align-items:center;gap:6px;justify-content:flex-end}',
@@ -136,10 +144,24 @@ window.__ModuleLoader__.load({
136
144
  '.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
145
  '.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
146
  '.tb-tabtitle{display:inline-flex;align-items:center;gap:5px;min-width:0}',
147
+ // 右栏 tab 的关闭按钮由宿主 dockkit chrome 渲染(本插件只提供正文与 chip):宿主 CSS 会在
148
+ // tab active / focus-within 时强制显示关闭按钮。这里只收紧带本插件标题(.tb-tabtitle)的 tab——
149
+ // 非悬停且非键盘聚焦时隐藏,悬停/聚焦时仍由宿主规则显示;:has 不被支持时整条规则被忽略,退回宿主行为。
150
+ '[data-dockkit-tab]:has(.tb-tabtitle):not(:hover):not(:focus-within) [data-dockkit-tab-close]{opacity:0!important;pointer-events:none!important}',
151
+ // 宿主在 hover / active 时用「标题右侧 30px 渐隐遮罩」给关闭按钮让位,而本插件 tab
152
+ // 只有内容宽(图标 + 任务看板 ≈ 71px)——遮罩从标题 41px 处开始,会把「板」吃掉。
153
+ // 比拉宽 tab 更省空间的做法:给 tab 右侧留出关闭按钮的 26px,并关掉这个遮罩;
154
+ // tab 只比原宽 +7px(≈100→107),标题完整、× 落在右侧留白里。
155
+ // 同时把宿主给 tab 的 min-width:80 放开(content-box 下它会让 tab 至少 80+padding 宽)。
156
+ '[data-dockkit-tab]:has(.tb-tabtitle){min-width:0;padding-right:24px}',
157
+ '[data-dockkit-tab]:has(.tb-tabtitle) [data-dockkit-tab-title]{mask-image:none!important}',
139
158
 
140
159
  // ── 右栏窄面板:lane 纵向堆叠 ──────────────────────────────
141
- '.tb-lanes{display:flex;flex-direction:column;gap:10px;min-height:0;flex:1 1 auto}',
160
+ '.tb-lanes{display:flex;flex-direction:column;gap:10px;min-height:0;flex:1 0 auto}',
142
161
  '.tb-page{position:relative}',
162
+ // 页面是唯一滚动容器:flex 子项默认 flex-shrink:1 会把看板压到 min-height,
163
+ // 内容从里面溢出、盖住页脚;这里统一禁止收缩,让 .tb-page 的 overflow-y:auto 生效。
164
+ '.tb-page > *{flex-shrink:0}',
143
165
  '.tb-card-titlebtn{cursor:pointer}',
144
166
  '.tb-card-titlebtn:hover{text-decoration:underline}',
145
167
  // ── 任务详情浮层 ─────────────────────────────────────────
@@ -195,6 +217,8 @@ window.__ModuleLoader__.load({
195
217
  '.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
218
  '.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
219
  '.tb-rich .tb-rich-table tr:last-child td{border-bottom:0}',
220
+ '.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)}',
221
+ '.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
222
  '.tb-detail-result{max-height:360px}',
199
223
  '.tb-detail-result-filled{border-left:3px solid var(--dsw-alias-state-success-primary,#16a34a)}',
200
224
  '.tb-detail-result[data-status=doing]{border-left:3px solid var(--dsw-alias-state-warn-primary,#d97706)}',
@@ -211,6 +235,8 @@ window.__ModuleLoader__.load({
211
235
  '.tb-page[data-narrow=true] .tb-board{grid-template-columns:minmax(0,1fr)}',
212
236
  '.tb-page[data-layout=medium] .tb-board{grid-template-columns:repeat(2,minmax(0,1fr))}',
213
237
  '.tb-page[data-narrow=true] .tb-col{min-height:0;height:auto;padding:8px 8px 9px}',
238
+ // 中/宽布局的空列占位在剩余高度里垂直居中(窄栏 lane 保持紧凑,不加高)。
239
+ '.tb-page[data-narrow=false] .tb-col > .tb-empty{flex:1 1 auto;display:flex;align-items:center;justify-content:center}',
214
240
  '.tb-page[data-narrow=true] .tb-empty{padding:8px}',
215
241
  '.tb-page[data-narrow=true] .tb-select{max-width:100%}',
216
242
  '.tb-page[data-narrow=true] .tb-foot{font-size:10px}',
@@ -224,6 +250,20 @@ window.__ModuleLoader__.load({
224
250
  '.tb-workspace-select{max-width:220px}',
225
251
  '.tb-platform-empty{margin-top:2px}',
226
252
 
253
+ // ── 组长条(主会话 / 工作区组长,v0.2.0)────────────────────
254
+ '.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}',
255
+ '.tb-lead{display:inline-flex;align-items:center;gap:5px;min-width:0;flex-wrap:wrap}',
256
+ '.tb-lead + .tb-lead{padding-left:10px;border-left:1px solid var(--dsw-alias-border-l1)}',
257
+ '.tb-lead-dot{width:7px;height:7px;border-radius:50%;flex:0 0 auto;background:var(--dsw-alias-state-success-primary)}',
258
+ '.tb-lead-dot[data-status=busy]{background:var(--dsw-alias-state-warn-primary)}',
259
+ '.tb-lead-dot[data-status=offline],.tb-lead-dot[data-status=missing],.tb-lead-dot[data-status=archived]{background:var(--dsw-alias-label-tertiary)}',
260
+ '.tb-lead-label{color:var(--dsw-alias-label-secondary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:230px}',
261
+ '.tb-lead-state{color:var(--dsw-alias-label-tertiary);white-space:nowrap}',
262
+ '.tb-lead-hint{flex-basis:100%;color:var(--dsw-alias-label-tertiary);line-height:1.45}',
263
+ '.tb-lead-btn{height:22px;padding:0 8px}',
264
+ '.tb-page[data-narrow=true] .tb-leads{padding:5px 8px;gap:2px 8px}',
265
+ '.tb-page[data-narrow=true] .tb-lead-label{max-width:160px}',
266
+
227
267
 
228
268
  // ── Apple 风格皮肤(最后追加,覆盖上面的基础样式)──────────
229
269
  // 设计参照 macOS / iOS:灰色画布 + 白色卡片、发丝分隔线、胶囊按钮、系统字体、柔和阴影。
@@ -272,17 +312,20 @@ window.__ModuleLoader__.load({
272
312
  '.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
313
  '.tb-card:hover{box-shadow:var(--tb-shadow-2);border-color:var(--tb-hairline);transform:translateY(-1px)}',
274
314
  '.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
315
  '.tb-empty{color:var(--tb-text-3);font-size:11px;padding:12px 6px;text-align:center;border:0;background:transparent}',
282
316
  '.tb-foot{color:var(--tb-text-3);font-size:10px;padding-top:2px;border-top:1px solid var(--tb-hairline-soft)}',
283
317
  '.tb-foot code{background:var(--dsw-alias-bg-skeleton);border-radius:5px;padding:1px 5px;font-size:9.5px}',
284
318
  '.tb-wsname{color:var(--tb-text-2);font-size:10.5px}',
285
319
  '.tb-toolbar-filter,.tb-toolbar-count{color:var(--tb-text-3);font-size:10.5px}',
320
+ // 组长条:与卡片同一套表面(颜色全部走官方 --dsw-* 主题变量)
321
+ '.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)}',
322
+ '.tb-lead + .tb-lead{border-left-color:var(--dsw-alias-border-l1)}',
323
+ '.tb-lead-label{color:var(--dsw-alias-label-secondary)}',
324
+ '.tb-lead-state,.tb-lead-hint{color:var(--dsw-alias-label-tertiary)}',
325
+ // 组长条按钮与同行文字统一字体/字号/行高/字重:按钮默认 500 字重 + 另一套
326
+ // 字体族 + line-height:1,会让「打开」「把当前对话设为主会话」比「组长 · xxx」
327
+ // 低约 1px(上下不齐)。这里改成完全继承组长条正文排版。
328
+ '.tb-leads .tb-lead-btn{font-family:inherit;font-size:inherit;font-weight:400;line-height:inherit}',
286
329
  // 详情浮层:灰色画布 + 白色分组卡片
287
330
  '.tb-detail-mask{background:rgba(15,17,21,.28);backdrop-filter:blur(12px) saturate(140%);padding:20px}',
288
331
  '.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 +369,15 @@ window.__ModuleLoader__.load({
326
369
  '.tb-rich .tb-rich-hr{border-top:1px solid var(--tb-hairline-soft)}',
327
370
  '.tb-rich a{color:var(--dsw-alias-link,var(--tb-accent));text-decoration:none}',
328
371
  '.tb-rich a:hover{text-decoration:underline}',
372
+
373
+ // ── 卡片精简 + 等高(t-33)──────────────────────────────────
374
+ // 卡片正文只剩标题,操作行固定贴底;高度统一用 min-height 兜住(--tb-card-h),
375
+ // 标题 / 按钮数量不同的卡片视觉等高,按钮行不会被固定高度裁掉。
376
+ // 标题 2 行截断(line-clamp),全文放 title 属性;行内编辑态不带 .tb-card-fixed,高度自适应。
377
+ '.tb-card-fixed{min-height:var(--tb-card-h,108px);gap:5px;padding:9px 10px 8px}',
378
+ '.tb-card-fixed .tb-card-title{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;line-height:1.4;word-break:break-word}',
379
+ '.tb-card-fixed .tb-card-actions{margin-top:auto;gap:3px 4px;padding-top:0}',
380
+ '.tb-card-fixed .tb-card-actions .tb-btn{height:22px;padding:0 7px;font-size:10.5px}',
329
381
  ].join('\n')
330
382
 
331
383
  function injectCss() {
@@ -348,7 +400,6 @@ window.__ModuleLoader__.load({
348
400
  'guide.description': '看板在右侧栏里:待开始 / 进行中 / 已完成 / 已归档,主 Agent 会自动挑待开始的任务派发。',
349
401
  'action.openBoard': '打开任务看板(右侧栏)',
350
402
  'page.title': '任务看板',
351
- 'page.subtitle': '主 Agent 只派单、子 Agent 干活。待开始列会被自动轮询派发。',
352
403
  'page.refresh': '刷新',
353
404
  'page.refreshing': '刷新中…',
354
405
  'poll.on': '每 {interval} 轮询',
@@ -360,10 +411,11 @@ window.__ModuleLoader__.load({
360
411
  'poll.resume': '恢复轮询',
361
412
  'poll.interval': '间隔',
362
413
  'dispatch.mode': '派发到',
414
+ 'dispatch.mode.workspace-lead': '工作区组长(推荐)',
363
415
  'dispatch.mode.new': '新对话',
364
416
  'dispatch.mode.creator': '回发起对话',
365
417
  'dispatch.mode.auto': '空闲会话',
366
- 'dispatch.modeHint': '新对话:每个任务在它自己的工作区新开一个对话执行(推荐);回发起对话:派回创建它的那个对话;空闲会话:自动挑一个空闲会话。',
418
+ 'dispatch.modeHint': '工作区组长:任务交给所属工作区的常驻组长执行(推荐);新对话:每个任务在它自己的工作区新开一个对话执行;回发起对话:派回创建它的那个对话;空闲会话:自动挑一个空闲会话。',
367
419
  'poll.skip.poll-disabled': '轮询已暂停',
368
420
  'poll.skip.agent-busy': '目标会话正在运行,稍后自动重试',
369
421
  'poll.skip.agent-offline': '任务指定的会话不在线',
@@ -376,10 +428,17 @@ window.__ModuleLoader__.load({
376
428
  'composer.addNote': '加备注',
377
429
  'composer.hideNote': '收起备注',
378
430
  'composer.submit': '添加到待开始',
431
+ 'composer.uploading': '图片上传中…',
432
+ 'composer.removeImage': '移除图片',
433
+ 'composer.imageTooMany': '一次最多粘贴 {n} 张图片,请分次粘贴',
434
+ 'composer.imageTooLarge': '单张图片不能超过 {mb} MB,已跳过 {n} 张',
435
+ 'composer.attachmentTooMany': '一条任务最多 {max} 个图片附件(当前 {n} 个)',
436
+ 'composer.imageFailed': '读取剪贴板图片失败',
379
437
  'composer.autoHint': '加进「待开始」后由主 Agent 自动接手,你只管加任务和看结论。',
380
438
  'composer.autoHintWorkspace': '加进「待开始」后由主 Agent 自动接手;任务会回到本对话执行(工作区:{name})。',
381
- 'card.workspace': '工作区 {name}',
382
439
  'composer.empty': '先写任务标题',
440
+ 'detail.imageLoading': '图片加载中…',
441
+ 'detail.imageFailed': '图片不可用',
383
442
  'column.todo': '待开始',
384
443
  'column.doing': '进行中',
385
444
  'column.done': '已完成',
@@ -400,7 +459,6 @@ window.__ModuleLoader__.load({
400
459
  'card.delete': '删除',
401
460
  'card.save': '保存',
402
461
  'card.cancel': '取消',
403
- 'card.deleteConfirm': '删除任务「{title}」?',
404
462
  'card.deleteConfirmShort': '确认删除',
405
463
  'card.detail': '详情',
406
464
  'card.openChat': '对话',
@@ -408,7 +466,6 @@ window.__ModuleLoader__.load({
408
466
  'detail.creatorSession': '发起对话',
409
467
  'detail.runSession': '执行对话',
410
468
  'detail.noSession': '(这条任务还没有关联对话)',
411
- 'detail.status': '状态',
412
469
  'detail.basicInfo': '基本信息',
413
470
  'detail.timeline': '时间线',
414
471
  'detail.workspace': '工作区',
@@ -422,7 +479,6 @@ window.__ModuleLoader__.load({
422
479
  'detail.source': '创建来源',
423
480
  'detail.sourceUser': '用户(看板 / 对话)',
424
481
  'detail.sourceAgent': '主 Agent(模型工具)',
425
- 'detail.notify': '派发提醒次数',
426
482
  'detail.id': '任务 id',
427
483
  'detail.note': '备注 / 验收标准',
428
484
  'detail.result': '完成结论',
@@ -431,15 +487,12 @@ window.__ModuleLoader__.load({
431
487
  'detail.emptyResult': '任务已完成,但主 Agent 还没有写结论。',
432
488
  'detail.emptyResultPending': '任务还没完成,完成后主 Agent 会把结论写在这里。',
433
489
  'detail.close': '关闭',
434
- 'card.assignee': '执行者',
435
- 'card.result': '结论',
436
- 'card.notified': '已通知 {n} 次',
437
490
  'card.ago.now': '刚刚',
438
491
  'card.ago.min': '{n} 分钟前',
439
492
  'card.ago.hour': '{n} 小时前',
440
493
  'card.ago.day': '{n} 天前',
441
- 'banner.presetMissing': '没有找到「派单看板模式」:{reason}',
442
- 'banner.presetBroken': '派单看板模式加载失败:{reason}',
494
+ 'banner.presetMissing': '没有找到「任务看板 · 工作区组长(自动)」:{reason}',
495
+ 'banner.presetBroken': '任务看板 · 工作区组长(自动)加载失败:{reason}',
443
496
  'banner.error': '连接看板服务失败:{message}',
444
497
  'banner.retrying': '连接断开,正在重试…',
445
498
  'action.archived': '已归档 {n} 个任务',
@@ -479,6 +532,34 @@ window.__ModuleLoader__.load({
479
532
  'poll.skip.workspace-offline': '这条任务所属工作区没有打开的对话:先在那个工作区开一个对话,或点「立即派发」改派',
480
533
  'poll.skip.creator-busy': '创建这条任务的对话正在运行,等它空下来再派',
481
534
  'poll.skip.creator-cold': '创建这条任务的对话还没激活(历史会话):在那边发一条消息,任务就会回到该对话执行;急的话点「立即派发」',
535
+ // v0.2.0 workspace-lead 路由的跳过原因(poll.lastSkipReason)
536
+ 'poll.skip.lead-busy': '工作区组长正在运行,等它空下来再派',
537
+ 'poll.skip.lead-unavailable': '工作区组长不可用:稍后重试,或在看板点「创建组长」',
538
+ 'poll.skip.lead-no-workspace': '无法解析任务的工作区:请从目标工作区的会话里重新加这条任务',
539
+
540
+ // v0.2.0 组长条 / 主会话绑定
541
+ 'lead.barLabel': '组长条',
542
+ 'lead.mainLabel': '主会话 · {title}',
543
+ 'lead.mainFallback': '主会话',
544
+ 'lead.unbound': '未绑定主会话',
545
+ 'lead.bind': '把当前对话设为主会话',
546
+ 'lead.rebind': '换绑',
547
+ 'lead.clear': '解除绑定',
548
+ 'lead.open': '打开',
549
+ 'lead.wsLabel': '组长 · {label}',
550
+ 'lead.wsFallback': '工作区',
551
+ 'lead.create': '创建组长',
552
+ 'lead.status.online': '在线',
553
+ 'lead.status.busy': '忙',
554
+ 'lead.status.offline': '离线',
555
+ 'lead.status.missing': '未创建',
556
+ 'lead.status.archived': '已归档',
557
+ 'lead.noCurrentSession': '拿不到当前会话 id:先在这个对话里打开右侧栏看板,再绑定主会话',
558
+ 'lead.bindOk': '已把当前对话设为主会话',
559
+ 'lead.clearOk': '已解除主会话绑定',
560
+ 'lead.ensureOk': '已创建工作区组长',
561
+ 'detail.lead': '组长',
562
+ 'detail.noLead': '(还没有组长)',
482
563
  }
483
564
 
484
565
  const DICT_EN = {
@@ -486,7 +567,6 @@ window.__ModuleLoader__.load({
486
567
  'guide.description': 'The board lives in this right sidebar: todo / in progress / done / archived, and the main agent dispatches todo tasks for you.',
487
568
  'action.openBoard': 'Open task board (right sidebar)',
488
569
  'page.title': 'Task board',
489
- 'page.subtitle': 'The main agent dispatches, subagents do the work. Todo tasks are polled and dispatched automatically.',
490
570
  'page.refresh': 'Refresh',
491
571
  'page.refreshing': 'Refreshing…',
492
572
  'poll.on': 'Polling every {interval}',
@@ -498,10 +578,11 @@ window.__ModuleLoader__.load({
498
578
  'poll.resume': 'Resume polling',
499
579
  'poll.interval': 'Interval',
500
580
  'dispatch.mode': 'Dispatch to',
581
+ 'dispatch.mode.workspace-lead': 'Workspace lead (recommended)',
501
582
  'dispatch.mode.new': 'New chat',
502
583
  'dispatch.mode.creator': 'Creator chat',
503
584
  '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.',
585
+ '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
586
  'poll.skip.poll-disabled': 'Polling paused',
506
587
  'poll.skip.agent-busy': 'Target session is busy; retrying later',
507
588
  'poll.skip.agent-offline': 'The task session is offline',
@@ -514,10 +595,17 @@ window.__ModuleLoader__.load({
514
595
  'composer.addNote': 'Add notes',
515
596
  'composer.hideNote': 'Hide notes',
516
597
  'composer.submit': 'Add to todo',
598
+ 'composer.uploading': 'Uploading image…',
599
+ 'composer.removeImage': 'Remove image',
600
+ 'composer.imageTooMany': 'At most {n} images per paste; paste them in smaller batches',
601
+ 'composer.imageTooLarge': 'Each image must be {mb} MB or smaller; skipped {n}',
602
+ 'composer.attachmentTooMany': 'At most {max} image attachments per task (currently {n})',
603
+ 'composer.imageFailed': 'Could not read the clipboard image',
517
604
  'composer.autoHint': 'The main agent picks up new todo tasks automatically — just add tasks and read the results.',
518
605
  'composer.autoHintWorkspace': 'The main agent picks this up automatically and runs it back in this conversation (workspace: {name}).',
519
- 'card.workspace': 'workspace {name}',
520
606
  'composer.empty': 'Title is required',
607
+ 'detail.imageLoading': 'Loading image…',
608
+ 'detail.imageFailed': 'Image unavailable',
521
609
  'column.todo': 'Todo',
522
610
  'column.doing': 'In progress',
523
611
  'column.done': 'Done',
@@ -538,7 +626,6 @@ window.__ModuleLoader__.load({
538
626
  'card.delete': 'Delete',
539
627
  'card.save': 'Save',
540
628
  'card.cancel': 'Cancel',
541
- 'card.deleteConfirm': 'Delete task "{title}"?',
542
629
  'card.deleteConfirmShort': 'Confirm delete',
543
630
  'card.detail': 'Details',
544
631
  'card.openChat': 'Chat',
@@ -546,7 +633,6 @@ window.__ModuleLoader__.load({
546
633
  'detail.creatorSession': 'Created in',
547
634
  'detail.runSession': 'Dispatched to',
548
635
  'detail.noSession': '(this task has no linked conversation yet)',
549
- 'detail.status': 'Status',
550
636
  'detail.basicInfo': 'Details',
551
637
  'detail.timeline': 'Timeline',
552
638
  'detail.workspace': 'Workspace',
@@ -560,7 +646,6 @@ window.__ModuleLoader__.load({
560
646
  'detail.source': 'Created by',
561
647
  'detail.sourceUser': 'User (board or chat)',
562
648
  'detail.sourceAgent': 'Main agent (model tool)',
563
- 'detail.notify': 'Dispatch reminders',
564
649
  'detail.id': 'Task id',
565
650
  'detail.note': 'Note / acceptance',
566
651
  'detail.result': 'Result',
@@ -569,15 +654,12 @@ window.__ModuleLoader__.load({
569
654
  'detail.emptyResult': 'Task is done but the main agent has not written a result yet.',
570
655
  'detail.emptyResultPending': 'Not finished yet; the main agent writes the result here when done.',
571
656
  'detail.close': 'Close',
572
- 'card.assignee': 'Assignee',
573
- 'card.result': 'Result',
574
- 'card.notified': 'Notified {n} times',
575
657
  'card.ago.now': 'just now',
576
658
  'card.ago.min': '{n} min ago',
577
659
  'card.ago.hour': '{n} h ago',
578
660
  'card.ago.day': '{n} d ago',
579
- 'banner.presetMissing': 'Dispatcher mode not found: {reason}',
580
- 'banner.presetBroken': 'Dispatcher mode failed to load: {reason}',
661
+ 'banner.presetMissing': 'Task-board workspace-lead mode not found: {reason}',
662
+ 'banner.presetBroken': 'Task-board workspace-lead mode failed to load: {reason}',
581
663
  'banner.error': 'Cannot reach the task board service: {message}',
582
664
  'banner.retrying': 'Connection lost, retrying…',
583
665
  'action.archived': 'Archived {n} tasks',
@@ -617,6 +699,34 @@ window.__ModuleLoader__.load({
617
699
  'poll.skip.workspace-offline': 'No open conversation in the task workspace: open one there, or click Dispatch now',
618
700
  'poll.skip.creator-busy': 'The conversation that created this task is running; retrying later',
619
701
  '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',
702
+ // v0.2.0 workspace-lead routing skip reasons (poll.lastSkipReason)
703
+ 'poll.skip.lead-busy': 'The workspace lead is running; it will retry once it is idle',
704
+ 'poll.skip.lead-unavailable': 'The workspace lead is unavailable: retry later, or click Create lead on the board',
705
+ 'poll.skip.lead-no-workspace': 'Cannot resolve the task workspace: re-add this task from a conversation inside the target workspace',
706
+
707
+ // v0.2.0 lead bar / main-session binding
708
+ 'lead.barLabel': 'Team leads',
709
+ 'lead.mainLabel': 'Main · {title}',
710
+ 'lead.mainFallback': 'Main',
711
+ 'lead.unbound': 'Main session not bound',
712
+ 'lead.bind': 'Set this chat as main session',
713
+ 'lead.rebind': 'Rebind',
714
+ 'lead.clear': 'Unbind',
715
+ 'lead.open': 'Open',
716
+ 'lead.wsLabel': 'Lead · {label}',
717
+ 'lead.wsFallback': 'workspace',
718
+ 'lead.create': 'Create lead',
719
+ 'lead.status.online': 'online',
720
+ 'lead.status.busy': 'busy',
721
+ 'lead.status.offline': 'offline',
722
+ 'lead.status.missing': 'not created',
723
+ 'lead.status.archived': 'archived',
724
+ 'lead.noCurrentSession': 'Current session id is unavailable: open this board from a conversation first, then bind the main session',
725
+ 'lead.bindOk': 'This conversation is now the main session',
726
+ 'lead.clearOk': 'Main session unbound',
727
+ 'lead.ensureOk': 'Workspace lead created',
728
+ 'detail.lead': 'Lead',
729
+ 'detail.noLead': '(no lead yet)',
620
730
  }
621
731
 
622
732
  function detectLang(locale) {
@@ -790,6 +900,127 @@ window.__ModuleLoader__.load({
790
900
  return sessionId.length > 8 ? sessionId.slice(-8) : sessionId
791
901
  }
792
902
 
903
+ /* ── v0.2.0 组长条(主会话 / 工作区组长)纯展示函数 ───────── */
904
+
905
+ // 「派发到」的四个合法值:v0.2.0 起默认 workspace-lead(缺省 / 未知一律回退它,不要回退 new)。
906
+ const DISPATCH_MODES = ['workspace-lead', 'new', 'creator', 'auto']
907
+
908
+ function dispatchModeOf(config) {
909
+ const mode = config && typeof config.dispatchMode === 'string' ? config.dispatchMode : ''
910
+ return DISPATCH_MODES.indexOf(mode) >= 0 ? mode : 'workspace-lead'
911
+ }
912
+
913
+ /** 组长 / 主会话状态点:missing(没有会话/未创建)/ offline(离线)/ busy(忙)/ online(在线)。 */
914
+ function leadStatusKey(lead) {
915
+ if (!lead || typeof lead !== 'object') return 'missing'
916
+ const sessionId = typeof lead.sessionId === 'string' ? lead.sessionId : ''
917
+ if (sessionId === '') return 'missing'
918
+ // 会话被归档:dsh 的归档门会拒绝它跑模型步进,任何调度都无效(v0.2.1)。
919
+ if (lead.archived === true) return 'archived'
920
+ // 没有 live 字段(旧 Host / 数据不完整)按离线处理,不误报绿点。
921
+ if (lead.live !== true) return 'offline'
922
+ if (lead.busy === true) return 'busy'
923
+ return 'online'
924
+ }
925
+
926
+ /** 主会话 / 组长展示名:title 取尾部 8 个字符,空串用 fallback(主会话的回退文案是「主会话」)。 */
927
+ function leadTitleTail(title, fallback) {
928
+ const text = typeof title === 'string' ? title.trim() : ''
929
+ const tail = text === '' ? '' : text.length > 8 ? text.slice(-8) : text
930
+ if (tail !== '') return tail
931
+ return typeof fallback === 'string' ? fallback : ''
932
+ }
933
+
934
+ /** 组长条的主会话一行:未绑定(leads.main 为 null)返回 null。 */
935
+ function leadMainRow(leads) {
936
+ const main = leads && typeof leads === 'object' ? leads.main : null
937
+ if (!main || typeof main !== 'object') return null
938
+ const sessionId = typeof main.sessionId === 'string' ? main.sessionId : ''
939
+ if (sessionId === '') return null
940
+ return {
941
+ sessionId,
942
+ title: typeof main.title === 'string' ? main.title : '',
943
+ status: leadStatusKey(main),
944
+ }
945
+ }
946
+
947
+ /** 任务卡片 / 详情的「组长」文案:优先 dispatchedSessionTitle,其次会话 id 尾 8;都没有返回空串。 */
948
+ function taskLeadLabel(task) {
949
+ if (!task || typeof task !== 'object') return ''
950
+ const title = typeof task.dispatchedSessionTitle === 'string' ? task.dispatchedSessionTitle.trim() : ''
951
+ if (title !== '') return title
952
+ const sessionId = typeof task.dispatchedSessionId === 'string' ? task.dispatchedSessionId : ''
953
+ return sessionId !== '' ? shortSession(sessionId) : ''
954
+ }
955
+
956
+ /** 看板可见任务涉及的工作区路径(去重;当前会话工作区排最前,保证没有任务也能「创建组长」)。 */
957
+ function taskWorkspaceCwds(tasks, currentCwd) {
958
+ const out = []
959
+ const push = (cwd) => {
960
+ if (typeof cwd !== 'string' || cwd === '') return
961
+ if (out.some((item) => samePath(item, cwd))) return
962
+ out.push(cwd)
963
+ }
964
+ push(currentCwd)
965
+ for (const task of Array.isArray(tasks) ? tasks : []) {
966
+ if (task) push(task.cwd)
967
+ }
968
+ return out
969
+ }
970
+
971
+ /**
972
+ * 组长条的工作区行(数据来自 Snapshot.leads,运行时视图):
973
+ * - all=true(完整看板):列出 snapshot.leads.workspaces 全部条目;
974
+ * - all=false(右栏本工作区看板):只列当前看板可见任务涉及的工作区
975
+ * (task.cwd 归一化 / 工作区 id 与组长条目的 cwd / key 比对,兼容两者),
976
+ * 没有组长的补一行 missing,让用户能点「创建组长」(ensure-workspace-lead)。
977
+ */
978
+ function workspaceLeadRows(leads, cwds, options) {
979
+ const all = !!(options && options.all)
980
+ const list = leads && Array.isArray(leads.workspaces) ? leads.workspaces : []
981
+ const wanted = (Array.isArray(cwds) ? cwds : []).filter((cwd) => typeof cwd === 'string' && cwd !== '')
982
+ const rows = []
983
+ const seen = []
984
+ for (const entry of list) {
985
+ if (!entry || typeof entry !== 'object') continue
986
+ const key = typeof entry.key === 'string' ? entry.key : ''
987
+ const cwd = typeof entry.cwd === 'string' ? entry.cwd : ''
988
+ if (!all) {
989
+ const matches = wanted.some(
990
+ (want) => samePath(want, cwd) || (key !== '' && samePath(want, key)),
991
+ )
992
+ if (!matches) continue
993
+ }
994
+ const status = leadStatusKey(entry)
995
+ rows.push({
996
+ key: key !== '' ? key : cwd,
997
+ label: typeof entry.label === 'string' && entry.label !== '' ? entry.label : baseName(cwd),
998
+ cwd,
999
+ sessionId: typeof entry.sessionId === 'string' ? entry.sessionId : '',
1000
+ title: typeof entry.title === 'string' ? entry.title : '',
1001
+ status,
1002
+ missing: status === 'missing',
1003
+ })
1004
+ if (cwd !== '') seen.push(cwd)
1005
+ }
1006
+ if (!all) {
1007
+ for (const cwd of wanted) {
1008
+ if (seen.some((item) => samePath(item, cwd))) continue
1009
+ rows.push({
1010
+ key: normalizePath(cwd),
1011
+ label: baseName(cwd),
1012
+ cwd,
1013
+ sessionId: '',
1014
+ title: '',
1015
+ status: 'missing',
1016
+ missing: true,
1017
+ })
1018
+ seen.push(cwd)
1019
+ }
1020
+ }
1021
+ return rows
1022
+ }
1023
+
793
1024
  /** 绝对时间(本地时区,YYYY-MM-DD HH:mm:ss):详情浮层用,空值显示破折号。 */
794
1025
  function fmtWhen(value) {
795
1026
  if (typeof value !== 'string' || value === '') return '—'
@@ -807,32 +1038,153 @@ window.__ModuleLoader__.load({
807
1038
  )
808
1039
  }
809
1040
 
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)
1041
+ /* ── 粘贴图片附件(v0.2.0)纯函数 ─────────────────────────── */
1042
+
1043
+ // note 里的短引用固定为 ![image](attachment://<uuid>)(契约见 docs/architecture.md §2.1)。
1044
+ const ATTACHMENT_ID_SOURCE = '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'
1045
+ const ATTACHMENT_REF_PATTERN = new RegExp('!\\[[^\\]]*\\]\\(attachment:\\/\\/(' + ATTACHMENT_ID_SOURCE + ')\\)', 'g')
1046
+ const MAX_PASTE_IMAGES = 4
1047
+ /** 详情浮层的附件 data URL 缓存上限(单任务最多 8 个引用;超出按插入顺序淘汰最旧的)。 */
1048
+ const MAX_ATTACHMENT_CACHE = 8
1049
+ /** 单张图片上限(与服务端 MAX_ATTACHMENT_BYTES 同值,§2.1):粘贴前按 file.size 预检,超限不发请求。 */
1050
+ const MAX_ATTACHMENT_BYTES = 5 * 1024 * 1024
1051
+ const MAX_ATTACHMENT_MB = MAX_ATTACHMENT_BYTES / (1024 * 1024)
1052
+ /** 单条任务 note 里最多几个不同附件引用(与服务端 MAX_TASK_ATTACHMENTS 同值,§2.1)。 */
1053
+ const MAX_NOTE_ATTACHMENTS = 8
1054
+
1055
+ function attachmentRef(id) {
1056
+ return '![image](attachment://' + String(id) + ')'
1057
+ }
1058
+
1059
+ /** 从若干段文本里按出现顺序取出去重的附件 id。 */
1060
+ function attachmentIdsIn() {
1061
+ const ids = []
1062
+ for (let i = 0; i < arguments.length; i += 1) {
1063
+ const text = arguments[i]
1064
+ if (typeof text !== 'string' || text === '') continue
1065
+ ATTACHMENT_REF_PATTERN.lastIndex = 0
1066
+ let match
1067
+ while ((match = ATTACHMENT_REF_PATTERN.exec(text)) !== null) {
1068
+ if (ids.indexOf(match[1]) === -1) ids.push(match[1])
833
1069
  }
834
1070
  }
835
- return nodes
1071
+ return ids
1072
+ }
1073
+
1074
+ /** 在备注末尾追加短引用(不重复追加同一 id)。 */
1075
+ function insertAttachmentRef(note, id) {
1076
+ const text = typeof note === 'string' ? note : ''
1077
+ const ref = attachmentRef(id)
1078
+ if (text.indexOf(ref) !== -1) return text
1079
+ const head = text.replace(/\s+$/, '')
1080
+ return head === '' ? ref : head + '\n' + ref
1081
+ }
1082
+
1083
+ /** 删除备注里的某个短引用(用于移除待提交图片)。 */
1084
+ function removeAttachmentRef(note, id) {
1085
+ const text = typeof note === 'string' ? note : ''
1086
+ const ref = attachmentRef(id)
1087
+ const escaped = ref.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
1088
+ return text
1089
+ .replace(new RegExp(escaped, 'g'), '')
1090
+ .replace(/[ \t]+\n/g, '\n')
1091
+ .replace(/\n{3,}/g, '\n\n')
1092
+ .trim()
1093
+ }
1094
+
1095
+ /**
1096
+ * 粘贴图片预算:先按单图大小上限(file.size 预检)剔除超限图片——超限的图不上传、不发请求,
1097
+ * 免得撞上 7 MB 请求体上限后只显示「网络错误」;再按一次粘贴最多 MAX_PASTE_IMAGES 张截断。
1098
+ * 返回 { accepted, tooLarge, skipped }。
1099
+ */
1100
+ function splitPasteImages(files) {
1101
+ const list = Array.isArray(files) ? files : []
1102
+ const withinSize = []
1103
+ let tooLarge = 0
1104
+ for (const file of list) {
1105
+ const size = file && typeof file.size === 'number' && Number.isFinite(file.size) ? file.size : 0
1106
+ if (size > MAX_ATTACHMENT_BYTES) {
1107
+ tooLarge += 1
1108
+ continue
1109
+ }
1110
+ withinSize.push(file)
1111
+ }
1112
+ const accepted = withinSize.slice(0, MAX_PASTE_IMAGES)
1113
+ return { accepted, tooLarge, skipped: withinSize.length - accepted.length }
1114
+ }
1115
+
1116
+ /** 上传计数 > 0:连续多次粘贴时只有全部结束才解除禁用(§5.2)。 */
1117
+ function isUploading(count) {
1118
+ return typeof count === 'number' && Number.isFinite(count) && count > 0
1119
+ }
1120
+
1121
+ /** 提交闸门:Enter 与提交按钮共用(上传中 / 忙 / 标题空 / 平台看板未选工作区都不提交)。 */
1122
+ function submitBlocked(flags) {
1123
+ const value = flags || {}
1124
+ if (isUploading(value.uploading)) return true
1125
+ if (value.busy) return true
1126
+ if (typeof value.title !== 'string' || value.title.trim() === '') return true
1127
+ return value.workspaceRequired === true
1128
+ }
1129
+
1130
+ /** note 里不同附件引用数超限时的具体提示(与服务端 bad-request 文案同源,§2.1);未超限返回 ''。 */
1131
+ function noteAttachmentLimitText(t, note) {
1132
+ const count = attachmentIdsIn(note).length
1133
+ if (count <= MAX_NOTE_ATTACHMENTS) return ''
1134
+ return t('composer.attachmentTooMany', { max: MAX_NOTE_ATTACHMENTS, n: count })
1135
+ }
1136
+
1137
+ /** 剪贴板事件里的图片文件(没有图片时返回空数组,调用方保持浏览器默认粘贴行为)。 */
1138
+ function clipboardImageFiles(event) {
1139
+ const clipboard = event && event.clipboardData
1140
+ const files = []
1141
+ const items = clipboard && clipboard.items
1142
+ if (items && typeof items.length === 'number') {
1143
+ for (let i = 0; i < items.length; i += 1) {
1144
+ const item = items[i]
1145
+ if (!item || item.kind !== 'file' || !/^image\//i.test(typeof item.type === 'string' ? item.type : '')) continue
1146
+ const file = typeof item.getAsFile === 'function' ? item.getAsFile() : null
1147
+ if (file) files.push(file)
1148
+ }
1149
+ }
1150
+ // 部分浏览器只填 clipboardData.files(没有 items):补一条兜底。
1151
+ if (files.length === 0 && clipboard && clipboard.files && typeof clipboard.files.length === 'number') {
1152
+ for (let i = 0; i < clipboard.files.length; i += 1) {
1153
+ const file = clipboard.files[i]
1154
+ if (file && /^image\//i.test(typeof file.type === 'string' ? file.type : '')) files.push(file)
1155
+ }
1156
+ }
1157
+ return files
1158
+ }
1159
+
1160
+ /** File → data URL(优先 FileReader;测试 / 极简环境退回 arrayBuffer + btoa)。 */
1161
+ function fileToDataUrl(file) {
1162
+ return new Promise((resolve, reject) => {
1163
+ if (typeof FileReader === 'function') {
1164
+ try {
1165
+ const reader = new FileReader()
1166
+ reader.onload = () => resolve(typeof reader.result === 'string' ? reader.result : '')
1167
+ reader.onerror = () => reject(reader.error || new Error('read failed'))
1168
+ reader.readAsDataURL(file)
1169
+ } catch (error) {
1170
+ reject(error)
1171
+ }
1172
+ return
1173
+ }
1174
+ if (file && typeof file.arrayBuffer === 'function' && typeof btoa === 'function') {
1175
+ Promise.resolve(file.arrayBuffer()).then((buffer) => {
1176
+ const bytes = new Uint8Array(buffer)
1177
+ let binary = ''
1178
+ const step = 0x8000
1179
+ for (let i = 0; i < bytes.length; i += step) {
1180
+ binary += String.fromCharCode.apply(null, bytes.subarray(i, i + step))
1181
+ }
1182
+ resolve('data:' + (typeof file.type === 'string' && file.type !== '' ? file.type : 'image/png') + ';base64,' + btoa(binary))
1183
+ }, reject)
1184
+ return
1185
+ }
1186
+ reject(new Error('FileReader unavailable'))
1187
+ })
836
1188
  }
837
1189
 
838
1190
  /**
@@ -986,8 +1338,58 @@ window.__ModuleLoader__.load({
986
1338
  return blocks
987
1339
  }
988
1340
 
1341
+ /**
1342
+ * 行内格式:**粗体**、`代码`、[链接](url)、![图片](attachment://<id>)。
1343
+ * options.attachment(id) 返回 {status:'ready',src} / {status:'loading'|'failed'};
1344
+ * 图片引用由详情浮层按需拉取,加载中 / 失败显示占位文本。
1345
+ */
1346
+ function renderInline(text, keyPrefix, options) {
1347
+ const nodes = []
1348
+ const pattern = /(!\[[^\]]*\]\(attachment:\/\/[0-9a-f-]{36}\)|\*\*[^*]+\*\*|`[^`]+`|\[[^\]]+\]\([^)]+\))/
1349
+ const parts = String(text).split(pattern)
1350
+ for (let i = 0; i < parts.length; i++) {
1351
+ const part = parts[i]
1352
+ if (part === '') continue
1353
+ if (part.startsWith('![') && part.includes('](') && part.endsWith(')')) {
1354
+ const close = part.indexOf('](')
1355
+ const alt = part.slice(2, close)
1356
+ const href = part.slice(close + 2, -1)
1357
+ const id = href.slice('attachment://'.length)
1358
+ const hit = options && typeof options.attachment === 'function' ? options.attachment(id) : null
1359
+ if (hit && typeof hit.src === 'string' && hit.src !== '') {
1360
+ nodes.push(h('img', { key: keyPrefix + 'i' + i, className: 'tb-rich-img', src: hit.src, alt: alt || '', loading: 'lazy' }))
1361
+ } else {
1362
+ const failed = hit && hit.status === 'failed'
1363
+ nodes.push(
1364
+ h(
1365
+ 'span',
1366
+ { key: keyPrefix + 'i' + i, className: 'tb-rich-attachment' },
1367
+ (failed ? options && options.attachmentFailedText : options && options.attachmentLoadingText) || '',
1368
+ ),
1369
+ )
1370
+ }
1371
+ } else if (part.startsWith('**') && part.endsWith('**') && part.length > 4) {
1372
+ nodes.push(h('strong', { key: keyPrefix + 'b' + i }, part.slice(2, -2)))
1373
+ } else if (part.startsWith('`') && part.endsWith('`') && part.length > 2) {
1374
+ nodes.push(h('code', { key: keyPrefix + 'c' + i }, part.slice(1, -1)))
1375
+ } else if (part.startsWith('[') && part.includes('](') && part.endsWith(')')) {
1376
+ const close = part.indexOf('](')
1377
+ const label = part.slice(1, close)
1378
+ const href = part.slice(close + 2, -1)
1379
+ nodes.push(
1380
+ /^https?:\/\//i.test(href)
1381
+ ? h('a', { key: keyPrefix + 'a' + i, href, target: '_blank', rel: 'noreferrer' }, label)
1382
+ : h('span', { key: keyPrefix + 'x' + i }, label),
1383
+ )
1384
+ } else {
1385
+ nodes.push(part)
1386
+ }
1387
+ }
1388
+ return nodes
1389
+ }
1390
+
989
1391
  /** 把解析结果渲染成 React 节点(两块看板的详情浮层共用)。 */
990
- function renderRichText(text) {
1392
+ function renderRichText(text, options) {
991
1393
  const blocks = parseRichText(text)
992
1394
  return blocks.map((block, index) => {
993
1395
  const key = 'b' + index
@@ -995,12 +1397,12 @@ window.__ModuleLoader__.load({
995
1397
  return h(
996
1398
  'h4',
997
1399
  { key, className: 'tb-rich-h', 'data-level': String(block.level) },
998
- renderInline(block.text, key + '_'),
1400
+ renderInline(block.text, key + '_', options),
999
1401
  )
1000
1402
  }
1001
1403
  if (block.type === 'hr') return h('hr', { key, className: 'tb-rich-hr' })
1002
1404
  if (block.type === 'quote') {
1003
- return h('blockquote', { key, className: 'tb-rich-quote' }, renderInline(block.text, key + '_'))
1405
+ return h('blockquote', { key, className: 'tb-rich-quote' }, renderInline(block.text, key + '_', options))
1004
1406
  }
1005
1407
  if (block.type === 'code') {
1006
1408
  return h('pre', { key, className: 'tb-rich-code' }, h('code', null, block.lines.join('\n')))
@@ -1009,7 +1411,7 @@ window.__ModuleLoader__.load({
1009
1411
  return h(
1010
1412
  block.ordered ? 'ol' : 'ul',
1011
1413
  { key, className: 'tb-rich-list' },
1012
- block.items.map((item, itemIndex) => h('li', { key: key + '_' + itemIndex }, renderInline(item, key + '_' + itemIndex + '_'))),
1414
+ block.items.map((item, itemIndex) => h('li', { key: key + '_' + itemIndex }, renderInline(item, key + '_' + itemIndex + '_', options))),
1013
1415
  )
1014
1416
  }
1015
1417
  if (block.type === 'table') {
@@ -1029,7 +1431,7 @@ window.__ModuleLoader__.load({
1029
1431
  h(
1030
1432
  'th',
1031
1433
  { key: key + 'h' + cellIndex, style: { textAlign: block.aligns[cellIndex] || 'left' } },
1032
- renderInline(cell, key + 'h' + cellIndex + '_'),
1434
+ renderInline(cell, key + 'h' + cellIndex + '_', options),
1033
1435
  ),
1034
1436
  ),
1035
1437
  ),
@@ -1042,7 +1444,7 @@ window.__ModuleLoader__.load({
1042
1444
  'tr',
1043
1445
  { key: key + 'r' + rowIndex },
1044
1446
  row.map((cell, cellIndex) =>
1045
- h('td', { key: key + 'c' + cellIndex }, renderInline(cell, key + 'r' + rowIndex + 'c' + cellIndex + '_')),
1447
+ h('td', { key: key + 'c' + cellIndex }, renderInline(cell, key + 'r' + rowIndex + 'c' + cellIndex + '_', options)),
1046
1448
  ),
1047
1449
  ),
1048
1450
  ),
@@ -1054,7 +1456,7 @@ window.__ModuleLoader__.load({
1054
1456
  const children = []
1055
1457
  block.lines.forEach((lineText, lineIndex) => {
1056
1458
  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 + '_')))
1459
+ if (lineText.trim() !== '') children.push(h('span', { key: key + 'l' + lineIndex }, renderInline(lineText, key + 'l' + lineIndex + '_', options)))
1058
1460
  })
1059
1461
  return h('p', { key }, children)
1060
1462
  })
@@ -1169,6 +1571,126 @@ window.__ModuleLoader__.load({
1169
1571
  )
1170
1572
  }
1171
1573
 
1574
+ /** 附件上传错误:bad-request 保留宿主的具体原因(MIME / 大小上限),其它走通用 i18n。 */
1575
+ function attachmentErrorText(t, error) {
1576
+ if (error && error.code === 'bad-request' && typeof error.message === 'string' && error.message !== '') return error.message
1577
+ return errorText(t, error)
1578
+ }
1579
+
1580
+ /**
1581
+ * 备注 textarea 的 paste 处理:有图片就上传并把短引用插进备注;没有图片返回 false,
1582
+ * 调用方不 preventDefault,普通文本粘贴保持浏览器默认行为。
1583
+ * opts: { t, setNote, setPending, beginUpload, endUpload, setNotice }
1584
+ *
1585
+ * 三条边界(§5.2):
1586
+ * 1. `file.size` 预检——单图 > 5 MB 直接提示、不发请求(避免撞 7 MB 请求体后只剩「网络错误」);
1587
+ * 2. 上传用计数(beginUpload / endUpload)——连续多次粘贴时不会提前解除提交禁用;
1588
+ * 3. 逐项 catch——单个文件读取 / 上传失败不丢弃同批已成功的图片(否则会留孤儿附件 + 丢用户输入)。
1589
+ */
1590
+ function handleNotePaste(event, opts) {
1591
+ const files = clipboardImageFiles(event)
1592
+ if (files.length === 0) return false
1593
+ if (event && typeof event.preventDefault === 'function') event.preventDefault()
1594
+ const budget = splitPasteImages(files)
1595
+ if (budget.tooLarge > 0) {
1596
+ opts.setNotice({
1597
+ tone: 'warn',
1598
+ text: opts.t('composer.imageTooLarge', { mb: MAX_ATTACHMENT_MB, n: budget.tooLarge }),
1599
+ })
1600
+ }
1601
+ if (budget.accepted.length === 0) return true
1602
+ if (typeof opts.beginUpload === 'function') opts.beginUpload()
1603
+ const uploads = budget.accepted.map((file) =>
1604
+ fileToDataUrl(file).then(
1605
+ (dataUrl) =>
1606
+ callRpc('upload-attachment', {
1607
+ dataUrl,
1608
+ name: typeof file.name === 'string' ? file.name : '',
1609
+ }).then((res) => ({ res, dataUrl })),
1610
+ (error) => ({ res: null, error }),
1611
+ ),
1612
+ )
1613
+ Promise.all(uploads)
1614
+ .then(
1615
+ (pairs) => {
1616
+ const uploaded = []
1617
+ let firstError = null
1618
+ for (const pair of pairs) {
1619
+ if (pair.error) {
1620
+ if (!firstError) firstError = { code: 'internal', message: String((pair.error && pair.error.message) || pair.error) }
1621
+ continue
1622
+ }
1623
+ const res = pair.res
1624
+ if (res && res.ok === true && res.value && typeof res.value.id === 'string' && res.value.id !== '') {
1625
+ uploaded.push(Object.assign({}, res.value, { preview: pair.dataUrl }))
1626
+ } else if (!firstError) {
1627
+ firstError = (res && res.error) || { code: 'internal', message: 'malformed upload response' }
1628
+ }
1629
+ }
1630
+ if (uploaded.length > 0) {
1631
+ opts.setPending((prev) => prev.concat(uploaded))
1632
+ opts.setNote((prev) => uploaded.reduce((text, item) => insertAttachmentRef(text, item.id), prev))
1633
+ }
1634
+ if (firstError) opts.setNotice({ tone: 'error', text: attachmentErrorText(opts.t, firstError) })
1635
+ else if (budget.tooLarge === 0 && budget.skipped > 0) {
1636
+ opts.setNotice({ tone: 'warn', text: opts.t('composer.imageTooMany', { n: MAX_PASTE_IMAGES }) })
1637
+ }
1638
+ },
1639
+ (error) => {
1640
+ opts.setNotice({
1641
+ tone: 'error',
1642
+ text: opts.t('composer.imageFailed') + (error && error.message ? ':' + error.message : ''),
1643
+ })
1644
+ },
1645
+ )
1646
+ .then(() => {
1647
+ if (typeof opts.endUpload === 'function') opts.endUpload()
1648
+ })
1649
+ return true
1650
+ }
1651
+
1652
+ /** 详情浮层按需拉取 note / result 里的附件(同一 id 只请求一次;失败下次打开再试)。 */
1653
+ function loadTaskAttachments(task, sourcesRef, setSources) {
1654
+ const ids = attachmentIdsIn(task && task.note, task && task.result)
1655
+ if (ids.length === 0) return
1656
+ const current = sourcesRef.current || {}
1657
+ const loading = []
1658
+ const next = Object.assign({}, current)
1659
+ for (const id of ids) {
1660
+ const existing = current[id]
1661
+ if (existing && existing.status !== 'failed') continue
1662
+ next[id] = { status: 'loading' }
1663
+ loading.push(id)
1664
+ }
1665
+ if (loading.length === 0) return
1666
+ sourcesRef.current = next
1667
+ setSources(next)
1668
+ for (const id of loading) {
1669
+ callRpc('attachment', { id }).then((res) => {
1670
+ const value = res && res.ok === true ? res.value : null
1671
+ const entry =
1672
+ value && typeof value.dataUrl === 'string' && value.dataUrl !== ''
1673
+ ? { status: 'ready', src: value.dataUrl }
1674
+ : { status: 'failed' }
1675
+ const updated = Object.assign({}, sourcesRef.current, { [id]: entry })
1676
+ // 上限淘汰(§5.2):只淘汰已就绪的最旧条目——刚更新的这张不能挤掉自己,
1677
+ // 还在飞的 loading 占位也不能删(删了会重复发请求,且占位会闪成「加载中」)。
1678
+ let overflow = Object.keys(updated).length - MAX_ATTACHMENT_CACHE
1679
+ if (overflow > 0) {
1680
+ for (const key of Object.keys(updated)) {
1681
+ if (overflow <= 0) break
1682
+ const item = updated[key]
1683
+ if (key === id || !item || item.status === 'loading') continue
1684
+ delete updated[key]
1685
+ overflow -= 1
1686
+ }
1687
+ }
1688
+ sourcesRef.current = updated
1689
+ setSources(updated)
1690
+ })
1691
+ }
1692
+ }
1693
+
1172
1694
  /** 定时器:优先 ctx.interval,退化 window.setInterval。返回停止函数。 */
1173
1695
  function every(fn, ms) {
1174
1696
  try {
@@ -1200,6 +1722,9 @@ window.__ModuleLoader__.load({
1200
1722
  let sidebarRightService = null
1201
1723
  // 客户端导航服务:用于「跳到对应对话」。
1202
1724
  let uiWorkspaceService = null
1725
+ // 最近一次渲染过的对话会话 id:根作用域的平台看板(main)拿不到 session 绑定,
1726
+ // 用会话 header / 右栏看板渲染时记下的值当「当前对话」;拿不到就禁用主会话绑定并提示。
1727
+ let lastConversationSessionId = ''
1203
1728
 
1204
1729
  /** 在看板里直接跳到某个会话(发起对话 / 执行对话)。 */
1205
1730
  function openSessionById(sessionId) {
@@ -1260,6 +1785,8 @@ window.__ModuleLoader__.load({
1260
1785
 
1261
1786
  function HeaderBoardAction(props) {
1262
1787
  const sessionId = props && typeof props.sessionId === 'string' ? props.sessionId : ''
1788
+ // 顺手记下当前对话 id(幂等赋值):根作用域的平台看板靠它绑定主会话,拿不到就禁用按钮。
1789
+ if (sessionId !== '') lastConversationSessionId = sessionId
1263
1790
  const [pending, setPending] = useState(-1)
1264
1791
  // 按钮打开的是「本工作区看板」,角标也按本工作区数;拿不到工作区(冷会话)时退回全平台数。
1265
1792
  const cwdRef = useRef('')
@@ -1432,7 +1959,6 @@ window.__ModuleLoader__.load({
1432
1959
  const t = bind.t
1433
1960
  const busy = bind.busy
1434
1961
  const editing = bind.editing
1435
- const now = bind.now
1436
1962
  const actions = bind.actions
1437
1963
  const task = props.task
1438
1964
  const status = task.status
@@ -1473,7 +1999,7 @@ window.__ModuleLoader__.load({
1473
1999
  'div',
1474
2000
  { className: 'tb-edit-actions' },
1475
2001
  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')),
2002
+ h('button', { type: 'button', className: 'tb-btn tb-btn-sm tb-btn-primary', disabled: busy !== '', onClick: () => actions.saveEdit() }, t('card.save')),
1477
2003
  ),
1478
2004
  ),
1479
2005
  )
@@ -1502,22 +2028,9 @@ window.__ModuleLoader__.load({
1502
2028
  cardActions.push([confirmingDelete ? 'deleteConfirmShort' : 'delete', requestDelete, false])
1503
2029
  }
1504
2030
 
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))
2031
+ // 卡片只留标题 + 操作按钮:note / result / lastError / id / 工作区 / 时间 /
2032
+ // 执行者 / 组长这些背景信息都在详情浮层里看(点标题或「详情」)。
2033
+ // 少这一整段后卡片能视觉等高(.tb-card-fixed 的 min-height + 操作行 margin-top:auto)。
1521
2034
 
1522
2035
  cardActions.unshift(['detail', () => actions.openDetail(task), false])
1523
2036
  const cardSessionId = sessionOf(task)
@@ -1527,14 +2040,15 @@ window.__ModuleLoader__.load({
1527
2040
 
1528
2041
  return h(
1529
2042
  'article',
1530
- { className: 'tb-card', style: { '--tb-accent': STATUS_ACCENT[status] } },
2043
+ { className: 'tb-card tb-card-fixed', style: { '--tb-accent': STATUS_ACCENT[status] } },
1531
2044
  h(
1532
2045
  'div',
1533
2046
  {
1534
2047
  className: 'tb-card-title tb-card-titlebtn',
1535
2048
  role: 'button',
1536
2049
  tabIndex: 0,
1537
- title: t('card.detail'),
2050
+ // 标题 2 行截断,title 属性兜住全文(鼠标悬停可看完整标题)
2051
+ title: task.title,
1538
2052
  onClick: () => actions.openDetail(task),
1539
2053
  onKeyDown: (event) => {
1540
2054
  if (event.key === 'Enter' || event.key === ' ') {
@@ -1545,12 +2059,6 @@ window.__ModuleLoader__.load({
1545
2059
  },
1546
2060
  task.title,
1547
2061
  ),
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
2062
  h(
1555
2063
  'div',
1556
2064
  { className: 'tb-card-actions' },
@@ -1580,11 +2088,16 @@ window.__ModuleLoader__.load({
1580
2088
  const t = bind.t
1581
2089
  const task = props.task
1582
2090
  if (!task) return null
2091
+ const richOptions = {
2092
+ attachment: (id) => (typeof bind.attachmentOf === 'function' ? bind.attachmentOf(id) : null),
2093
+ attachmentLoadingText: t('detail.imageLoading'),
2094
+ attachmentFailedText: t('detail.imageFailed'),
2095
+ }
1583
2096
  const metaRows = [
1584
2097
  [t('detail.workspace'), task.cwd || '—'],
2098
+ [t('detail.lead'), taskLeadLabel(task) || t('detail.noLead')],
1585
2099
  [t('detail.assignee'), task.assignee || t('detail.assigneeAuto')],
1586
2100
  [t('detail.source'), task.source === 'agent' ? t('detail.sourceAgent') : t('detail.sourceUser')],
1587
- [t('detail.notify'), String(task.notificationCount || 0)],
1588
2101
  [t('detail.id'), task.id],
1589
2102
  ]
1590
2103
  const timeRows = [
@@ -1632,9 +2145,6 @@ window.__ModuleLoader__.load({
1632
2145
  { className: 'tb-detail-chip' },
1633
2146
  task.source === 'agent' ? t('detail.sourceAgent') : t('detail.sourceUser'),
1634
2147
  ),
1635
- task.notificationCount > 0
1636
- ? h('span', { className: 'tb-detail-chip' }, t('detail.notify') + ' ' + String(task.notificationCount))
1637
- : null,
1638
2148
  ),
1639
2149
  h('h2', { className: 'tb-detail-title' }, task.title),
1640
2150
  ),
@@ -1661,7 +2171,7 @@ window.__ModuleLoader__.load({
1661
2171
  'data-status': task.status,
1662
2172
  },
1663
2173
  task.result
1664
- ? renderRichText(task.result)
2174
+ ? renderRichText(task.result, richOptions)
1665
2175
  : task.status === 'done'
1666
2176
  ? t('detail.emptyResult')
1667
2177
  : t('detail.emptyResultPending'),
@@ -1674,7 +2184,7 @@ window.__ModuleLoader__.load({
1674
2184
  h(
1675
2185
  'div',
1676
2186
  { className: 'tb-detail-text tb-rich' + (task.note ? '' : ' tb-detail-muted') },
1677
- task.note ? renderRichText(task.note) : t('detail.emptyNote'),
2187
+ task.note ? renderRichText(task.note, richOptions) : t('detail.emptyNote'),
1678
2188
  ),
1679
2189
  ),
1680
2190
  h(
@@ -1773,7 +2283,157 @@ window.__ModuleLoader__.load({
1773
2283
  )
1774
2284
  }
1775
2285
 
1776
- return { Banner, Col, Detail }
2286
+ /**
2287
+ * 组长条(两块看板共用,v0.2.0):主会话绑定状态 + 当前看板涉及的工作区组长。
2288
+ * 数据来自 snapshot.leads(运行时视图:组长启停 / 忙闲变化不 bump revision,所以每次渲染都读最新快照);
2289
+ * 动作走 v0.2.0 RPC:bind-main-session / clear-main-session / ensure-workspace-lead。
2290
+ */
2291
+ function LeadBar() {
2292
+ const t = bind.t
2293
+ const busy = typeof bind.busy === 'string' ? bind.busy : ''
2294
+ const busyNow = busy !== ''
2295
+ const currentSessionId = typeof bind.currentSessionId === 'string' ? bind.currentSessionId : ''
2296
+ const leads = bind.leads && typeof bind.leads === 'object' ? bind.leads : null
2297
+ const main = leadMainRow(leads)
2298
+ const rows = Array.isArray(bind.leadRows) ? bind.leadRows : []
2299
+ const actions = bind.leadActions || {}
2300
+ const bindHint = currentSessionId === '' ? t('lead.noCurrentSession') : t('lead.bind')
2301
+ const dot = (status) =>
2302
+ h('span', { key: 'dot', className: 'tb-lead-dot', 'data-status': status, 'aria-hidden': 'true' })
2303
+ const stateText = (status) =>
2304
+ h('span', { key: 'state', className: 'tb-lead-state' }, t('lead.status.' + status))
2305
+ const bindButton = (labelKey, key) =>
2306
+ h(
2307
+ 'button',
2308
+ {
2309
+ key,
2310
+ type: 'button',
2311
+ className: 'tb-btn tb-btn-sm tb-btn-ghost tb-lead-btn',
2312
+ disabled: busyNow || currentSessionId === '',
2313
+ title: bindHint,
2314
+ onClick: () => {
2315
+ if (typeof actions.bindMain === 'function') actions.bindMain()
2316
+ },
2317
+ },
2318
+ t(labelKey),
2319
+ )
2320
+
2321
+ const mainBits = []
2322
+ if (main) {
2323
+ mainBits.push(dot(main.status))
2324
+ mainBits.push(
2325
+ h(
2326
+ 'span',
2327
+ { key: 'label', className: 'tb-lead-label', title: main.title || main.sessionId },
2328
+ t('lead.mainLabel', { title: leadTitleTail(main.title, t('lead.mainFallback')) }),
2329
+ ),
2330
+ )
2331
+ mainBits.push(stateText(main.status))
2332
+ mainBits.push(
2333
+ h(
2334
+ 'button',
2335
+ {
2336
+ key: 'open',
2337
+ type: 'button',
2338
+ className: 'tb-btn tb-btn-sm tb-btn-ghost tb-lead-btn',
2339
+ title: main.sessionId,
2340
+ onClick: () => {
2341
+ if (typeof actions.openSession === 'function') actions.openSession(main.sessionId)
2342
+ },
2343
+ },
2344
+ t('lead.open'),
2345
+ ),
2346
+ )
2347
+ mainBits.push(bindButton('lead.rebind', 'rebind'))
2348
+ mainBits.push(
2349
+ h(
2350
+ 'button',
2351
+ {
2352
+ key: 'clear',
2353
+ type: 'button',
2354
+ className: 'tb-btn tb-btn-sm tb-btn-ghost tb-lead-btn',
2355
+ disabled: busyNow,
2356
+ onClick: () => {
2357
+ if (typeof actions.clearMain === 'function') actions.clearMain()
2358
+ },
2359
+ },
2360
+ t('lead.clear'),
2361
+ ),
2362
+ )
2363
+ } else {
2364
+ mainBits.push(dot('missing'))
2365
+ mainBits.push(h('span', { key: 'label', className: 'tb-lead-label' }, t('lead.unbound')))
2366
+ mainBits.push(bindButton('lead.bind', 'bind'))
2367
+ if (currentSessionId === '') {
2368
+ mainBits.push(h('span', { key: 'hint', className: 'tb-lead-hint' }, t('lead.noCurrentSession')))
2369
+ }
2370
+ }
2371
+
2372
+ const cells = [
2373
+ h(
2374
+ 'div',
2375
+ {
2376
+ key: 'main',
2377
+ className: 'tb-lead tb-lead-main',
2378
+ 'data-status': main ? main.status : 'missing',
2379
+ title: main ? main.title || main.sessionId : '',
2380
+ },
2381
+ mainBits,
2382
+ ),
2383
+ ]
2384
+ rows.forEach((row) => {
2385
+ const bits = [
2386
+ dot(row.status),
2387
+ h(
2388
+ 'span',
2389
+ { key: 'label', className: 'tb-lead-label', title: row.cwd || row.sessionId || '' },
2390
+ t('lead.wsLabel', { label: row.label || t('lead.wsFallback') }),
2391
+ ),
2392
+ stateText(row.status),
2393
+ ]
2394
+ if (row.missing || row.status === 'archived') {
2395
+ bits.push(
2396
+ h(
2397
+ 'button',
2398
+ {
2399
+ key: 'create',
2400
+ type: 'button',
2401
+ className: 'tb-btn tb-btn-sm tb-btn-ghost tb-lead-btn',
2402
+ disabled: busyNow || row.cwd === '',
2403
+ title: row.cwd,
2404
+ onClick: () => {
2405
+ if (typeof actions.ensureLead === 'function') actions.ensureLead(row.cwd)
2406
+ },
2407
+ },
2408
+ t('lead.create'),
2409
+ ),
2410
+ )
2411
+ } else {
2412
+ bits.push(
2413
+ h(
2414
+ 'button',
2415
+ {
2416
+ key: 'open',
2417
+ type: 'button',
2418
+ className: 'tb-btn tb-btn-sm tb-btn-ghost tb-lead-btn',
2419
+ disabled: row.sessionId === '',
2420
+ title: row.sessionId,
2421
+ onClick: () => {
2422
+ if (typeof actions.openSession === 'function') actions.openSession(row.sessionId)
2423
+ },
2424
+ },
2425
+ t('lead.open'),
2426
+ ),
2427
+ )
2428
+ }
2429
+ cells.push(
2430
+ h('div', { key: 'ws:' + row.key, className: 'tb-lead tb-lead-ws', 'data-status': row.status }, bits),
2431
+ )
2432
+ })
2433
+ return h('div', { className: 'tb-leads', role: 'group', 'aria-label': t('lead.barLabel') }, cells)
2434
+ }
2435
+
2436
+ return { Banner, Col, Detail, LeadBar }
1777
2437
  }
1778
2438
 
1779
2439
  /* ── 看板页 ─────────────────────────────────────────────── */
@@ -1785,7 +2445,9 @@ window.__ModuleLoader__.load({
1785
2445
  function BoardTab(props) {
1786
2446
  const useTabInfo = props ? props.useTabInfo : undefined
1787
2447
  // 右栏 tab 是 session scope,宿主会传当前会话 id:任务记下它,派发时回到这个对话。
2448
+ // 同一个 id 也是「把当前对话设为主会话」(bind-main-session)的入参。
1788
2449
  const sessionId = props && typeof props.sessionId === 'string' ? props.sessionId : ''
2450
+ if (sessionId !== '') lastConversationSessionId = sessionId
1789
2451
  const tabInfo = (() => {
1790
2452
  if (typeof useTabInfo !== 'function') return null
1791
2453
  try {
@@ -1806,10 +2468,15 @@ window.__ModuleLoader__.load({
1806
2468
  const boardBindRef = useRef(null)
1807
2469
  const boardPiecesRef = useRef(null)
1808
2470
  const [notice, setNotice] = useState(null)
1809
- const [now, setNow] = useState(Date.now())
1810
2471
  const [title, setTitle] = useState('')
1811
2472
  const [note, setNote] = useState('')
1812
2473
  const [showNote, setShowNote] = useState(false)
2474
+ // v0.2.0:待提交的粘贴图片({id, preview, ...})与详情浮层的附件 data URL 缓存。
2475
+ const [attachments, setAttachments] = useState([])
2476
+ // 上传中的请求计数(不是布尔):连续多次粘贴时,只有全部结束才解除提交禁用。
2477
+ const [uploadingCount, setUploadingCount] = useState(0)
2478
+ const [attachmentSources, setAttachmentSources] = useState({})
2479
+ const attachmentSourcesRef = useRef({})
1813
2480
  const [editing, setEditing] = useState(null)
1814
2481
  const aliveRef = useRef(true)
1815
2482
 
@@ -1875,12 +2542,6 @@ window.__ModuleLoader__.load({
1875
2542
  return () => stop()
1876
2543
  }, [refresh])
1877
2544
 
1878
- // 相对时间每分钟重算一次。
1879
- useEffect(() => {
1880
- const stop = every(() => setNow(Date.now()), 30000)
1881
- return () => stop()
1882
- }, [])
1883
-
1884
2545
  const config = (snap && snap.config) || { pollEnabled: true, pollIntervalMs: 15000 }
1885
2546
  const allTasks = (snap && snap.tasks) || []
1886
2547
  const poll = (snap && snap.poll) || {}
@@ -1916,6 +2577,10 @@ window.__ModuleLoader__.load({
1916
2577
  ).length
1917
2578
  const groups = groupTasks(tasks)
1918
2579
  const preset = (snap && snap.preset) || null
2580
+ // v0.2.0 组长条:leads 是运行时视图(组长启停 / 忙闲不 bump revision),每次渲染都读最新值;
2581
+ // 右栏只列当前看板可见任务涉及的工作区,没组长的补「创建组长」入口。
2582
+ const leads = (snap && snap.leads) || null
2583
+ const leadRows = workspaceLeadRows(leads, taskWorkspaceCwds(tasks, cwdForHint), { all: false })
1919
2584
 
1920
2585
  /** 统一执行一次写操作:忙态 + 错误提示 + 成功后刷新。 */
1921
2586
  const run = useCallback(
@@ -1938,11 +2603,19 @@ window.__ModuleLoader__.load({
1938
2603
  )
1939
2604
 
1940
2605
  function submitTask() {
2606
+ // 上传中(计数 > 0)不提交:Enter 与按钮共用同一闸门,避免 note 里只有一半附件引用。
2607
+ if (isUploading(uploadingCount)) return
1941
2608
  const trimmedTitle = title.trim()
1942
2609
  if (trimmedTitle === '') {
1943
2610
  setNotice({ tone: 'warn', text: t('composer.empty') })
1944
2611
  return
1945
2612
  }
2613
+ // 客户端预检:note 里不同附件引用 > 8 时给具体提示(与服务端 bad-request 文案同源,§2.1)。
2614
+ const limitText = noteAttachmentLimitText(t, note)
2615
+ if (limitText !== '') {
2616
+ setNotice({ tone: 'error', text: limitText })
2617
+ return
2618
+ }
1946
2619
  const payload = { title: trimmedTitle }
1947
2620
  if (note.trim() !== '') payload.note = note.trim()
1948
2621
  if (sessionId !== '') payload.sessionId = sessionId
@@ -1951,6 +2624,7 @@ window.__ModuleLoader__.load({
1951
2624
  setTitle('')
1952
2625
  setNote('')
1953
2626
  setShowNote(false)
2627
+ setAttachments([])
1954
2628
  })
1955
2629
  }
1956
2630
 
@@ -2006,10 +2680,50 @@ window.__ModuleLoader__.load({
2006
2680
  setNotice({ tone: 'warn', text: t('composer.empty') })
2007
2681
  return
2008
2682
  }
2683
+ // 编辑备注同样受单任务 8 个附件引用的限制(文本里手写的引用也算)。
2684
+ const limitText = noteAttachmentLimitText(t, editing.note)
2685
+ if (limitText !== '') {
2686
+ setNotice({ tone: 'error', text: limitText })
2687
+ return
2688
+ }
2009
2689
  updateTask(editing.id, { title: trimmedTitle, note: String(editing.note || '').trim() })
2010
2690
  setEditing(null)
2011
2691
  }
2012
2692
 
2693
+ /** 备注粘贴:有图片就走上传 + 短引用;没有图片返回 false(保持默认文本粘贴)。 */
2694
+ function onNotePaste(event) {
2695
+ return handleNotePaste(event, {
2696
+ t,
2697
+ setNote,
2698
+ setPending: setAttachments,
2699
+ beginUpload: () => setUploadingCount((value) => value + 1),
2700
+ endUpload: () => setUploadingCount((value) => Math.max(0, value - 1)),
2701
+ setNotice,
2702
+ })
2703
+ }
2704
+
2705
+ /** 移除一张待提交图片:缩略图与 note 里的引用一起删。 */
2706
+ function removePendingAttachment(id) {
2707
+ setAttachments((prev) => prev.filter((item) => item.id !== id))
2708
+ setNote((prev) => removeAttachmentRef(prev, id))
2709
+ }
2710
+
2711
+ /* ── 组长条动作(v0.2.0)────────────────────────────────── */
2712
+ // 三个新 RPC:bind-main-session {sessionId} / clear-main-session {} / ensure-workspace-lead {cwd}。
2713
+ // 失败走 run() 的顶部错误条(errorText),不乐观更新、不崩。
2714
+ const leadActions = {
2715
+ bindMain: () => {
2716
+ if (sessionId === '') return
2717
+ run('lead:bind', () => callRpc('bind-main-session', { sessionId }), t('lead.bindOk'))
2718
+ },
2719
+ clearMain: () => run('lead:clear', () => callRpc('clear-main-session', {}), t('lead.clearOk')),
2720
+ ensureLead: (cwd) => {
2721
+ if (typeof cwd !== 'string' || cwd === '') return
2722
+ run('lead:ensure', () => callRpc('ensure-workspace-lead', { cwd }), t('lead.ensureOk'))
2723
+ },
2724
+ openSession: (sessionIdToOpen) => openSessionById(sessionIdToOpen),
2725
+ }
2726
+
2013
2727
  /* ── 子组件(与平台看板共用)──────────────────────────── */
2014
2728
  // 组件身份保持稳定:bind 存在 ref 里,每次渲染只更新字段;pieces 只创建一次。
2015
2729
  // 否则轮询每 2s 刷新都会换掉组件类型 → React 卸载重建 → 详情浮层闪一下、滚动位置丢。
@@ -2019,7 +2733,10 @@ window.__ModuleLoader__.load({
2019
2733
  removeTask,
2020
2734
  requestDelete,
2021
2735
  isConfirmingDelete: (id) => confirmDeleteId === id,
2022
- openDetail: (task) => setDetailId(task.id),
2736
+ openDetail: (task) => {
2737
+ if (task) loadTaskAttachments(task, attachmentSourcesRef, setAttachmentSources)
2738
+ setDetailId(task.id)
2739
+ },
2023
2740
  openSession: (task) => openSessionById(task && (task.dispatchedSessionId || task.sessionId)),
2024
2741
  startEdit,
2025
2742
  saveEdit,
@@ -2031,23 +2748,32 @@ window.__ModuleLoader__.load({
2031
2748
  t,
2032
2749
  busy: '',
2033
2750
  editing: null,
2034
- now: 0,
2035
2751
  actions: boardActions,
2036
2752
  fallbackDispatchSessionId: '',
2037
2753
  lastDispatchTaskId: '',
2754
+ leads: null,
2755
+ leadRows: [],
2756
+ currentSessionId: '',
2757
+ leadActions,
2038
2758
  }
2039
2759
  }
2040
2760
  boardBindRef.current.t = t
2041
2761
  boardBindRef.current.busy = busy
2042
2762
  boardBindRef.current.editing = editing
2043
- boardBindRef.current.now = now
2044
2763
  boardBindRef.current.actions = boardActions
2764
+ boardBindRef.current.attachmentOf = (id) => attachmentSources[id] || null
2045
2765
  boardBindRef.current.fallbackDispatchSessionId = fallbackDispatchSessionId
2046
2766
  boardBindRef.current.lastDispatchTaskId = (poll && poll.lastDispatchTaskId) || ''
2767
+ // 组长条字段每次都刷新:leads 是运行时视图,revision 不变也会变。
2768
+ boardBindRef.current.leads = leads
2769
+ boardBindRef.current.leadRows = leadRows
2770
+ boardBindRef.current.currentSessionId = sessionId
2771
+ boardBindRef.current.leadActions = leadActions
2047
2772
  if (boardPiecesRef.current === null) boardPiecesRef.current = createBoardPieces(boardBindRef.current)
2048
2773
  const Banner = boardPiecesRef.current.Banner
2049
2774
  const Col = boardPiecesRef.current.Col
2050
2775
  const Detail = boardPiecesRef.current.Detail
2776
+ const LeadBar = boardPiecesRef.current.LeadBar
2051
2777
 
2052
2778
  /* ── 顶部状态文案 ─────────────────────────────────────── */
2053
2779
 
@@ -2132,13 +2858,13 @@ window.__ModuleLoader__.load({
2132
2858
  'select',
2133
2859
  {
2134
2860
  className: 'tb-select',
2135
- value: config.dispatchMode || 'new',
2861
+ value: dispatchModeOf(config),
2136
2862
  disabled: busyNow,
2137
2863
  title: t('dispatch.modeHint'),
2138
2864
  'aria-label': t('dispatch.mode'),
2139
2865
  onChange: (event) => setConfig({ dispatchMode: event.target.value }),
2140
2866
  },
2141
- ['new', 'creator', 'auto'].map((mode) => h('option', { key: mode, value: mode }, t('dispatch.mode.' + mode))),
2867
+ DISPATCH_MODES.map((mode) => h('option', { key: mode, value: mode }, t('dispatch.mode.' + mode))),
2142
2868
  ),
2143
2869
  ),
2144
2870
  h(
@@ -2159,6 +2885,7 @@ window.__ModuleLoader__.load({
2159
2885
  ),
2160
2886
  ),
2161
2887
 
2888
+ h(LeadBar, { key: 'leads' }),
2162
2889
  presetBanner ? h(Banner, { item: presetBanner }) : null,
2163
2890
  notice ? h(Banner, { item: notice, onClose: () => setNotice(null) }) : null,
2164
2891
  failures > 0 && error
@@ -2199,7 +2926,7 @@ window.__ModuleLoader__.load({
2199
2926
  {
2200
2927
  type: 'button',
2201
2928
  className: 'tb-btn tb-btn-primary',
2202
- disabled: busyNow || title.trim() === '',
2929
+ disabled: submitBlocked({ busy: busyNow, uploading: uploadingCount, title }),
2203
2930
  onClick: submitTask,
2204
2931
  },
2205
2932
  t('composer.submit'),
@@ -2211,8 +2938,38 @@ window.__ModuleLoader__.load({
2211
2938
  placeholder: t('composer.note'),
2212
2939
  value: note,
2213
2940
  onChange: (event) => setNote(event.target.value),
2941
+ onPaste: onNotePaste,
2214
2942
  })
2215
2943
  : null,
2944
+ attachments.length > 0
2945
+ ? h(
2946
+ 'div',
2947
+ { className: 'tb-attach-strip' },
2948
+ attachments.map((item) =>
2949
+ h(
2950
+ 'div',
2951
+ { key: item.id, className: 'tb-attach-item' },
2952
+ h('img', {
2953
+ className: 'tb-attach-thumb',
2954
+ src: item.preview,
2955
+ alt: typeof item.name === 'string' ? item.name : '',
2956
+ title: t('composer.removeImage'),
2957
+ }),
2958
+ h(
2959
+ 'button',
2960
+ {
2961
+ type: 'button',
2962
+ className: 'tb-attach-remove',
2963
+ onClick: () => removePendingAttachment(item.id),
2964
+ 'aria-label': t('composer.removeImage'),
2965
+ title: t('composer.removeImage'),
2966
+ },
2967
+ '\u00d7',
2968
+ ),
2969
+ ),
2970
+ ),
2971
+ )
2972
+ : null,
2216
2973
  h(
2217
2974
  'div',
2218
2975
  { className: 'tb-composer-meta' },
@@ -2221,6 +2978,7 @@ window.__ModuleLoader__.load({
2221
2978
  { type: 'button', className: 'tb-linkbtn', onClick: () => setShowNote(!showNote), 'aria-expanded': showNote ? 'true' : 'false' },
2222
2979
  showNote ? t('composer.hideNote') : t('composer.addNote'),
2223
2980
  ),
2981
+ isUploading(uploadingCount) ? h('span', { className: 'tb-hint' }, t('composer.uploading')) : null,
2224
2982
  h(
2225
2983
  'span',
2226
2984
  { className: 'tb-hint' },
@@ -2317,10 +3075,15 @@ window.__ModuleLoader__.load({
2317
3075
  const boardBindRef = useRef(null)
2318
3076
  const boardPiecesRef = useRef(null)
2319
3077
  const [notice, setNotice] = useState(null)
2320
- const [now, setNow] = useState(Date.now())
2321
3078
  const [title, setTitle] = useState('')
2322
3079
  const [note, setNote] = useState('')
2323
3080
  const [showNote, setShowNote] = useState(false)
3081
+ // v0.2.0:与右栏看板同一套粘贴图片 / 详情附件缓存。
3082
+ const [attachments, setAttachments] = useState([])
3083
+ // 上传中的请求计数(不是布尔):连续多次粘贴时,只有全部结束才解除提交禁用。
3084
+ const [uploadingCount, setUploadingCount] = useState(0)
3085
+ const [attachmentSources, setAttachmentSources] = useState({})
3086
+ const attachmentSourcesRef = useRef({})
2324
3087
  const [editing, setEditing] = useState(null)
2325
3088
  const [filterPath, setFilterPath] = useState('')
2326
3089
  const [workspaceCwd, setWorkspaceCwd] = useState('')
@@ -2365,12 +3128,6 @@ window.__ModuleLoader__.load({
2365
3128
  return () => stop()
2366
3129
  }, [refresh])
2367
3130
 
2368
- // 相对时间每分钟重算一次。
2369
- useEffect(() => {
2370
- const stop = every(() => setNow(Date.now()), 30000)
2371
- return () => stop()
2372
- }, [])
2373
-
2374
3131
  const config = (snap && snap.config) || { pollEnabled: true, pollIntervalMs: 15000 }
2375
3132
  const allTasks = (snap && snap.tasks) || []
2376
3133
  const workspaces = (snap && snap.workspaces) || []
@@ -2394,6 +3151,11 @@ window.__ModuleLoader__.load({
2394
3151
  const fallbackDispatchSessionId =
2395
3152
  poll && poll.lastDispatchSessionId && (poll.lastDispatchTaskId || doingAll.length === 1) ? poll.lastDispatchSessionId : ''
2396
3153
  const detailTask = detailId ? allTasks.find((task) => task && task.id === detailId) || null : null
3154
+ // v0.2.0 组长条:完整看板列出全部工作区组长(leads 是运行时视图,每次渲染都读最新值)。
3155
+ // 根作用域的 main 页拿不到 session 绑定:用最近渲染过的对话 id 当「当前对话」,没有就禁用绑定按钮。
3156
+ const leads = (snap && snap.leads) || null
3157
+ const leadRows = workspaceLeadRows(leads, [], { all: true })
3158
+ const currentSessionId = lastConversationSessionId
2397
3159
 
2398
3160
  /** 统一执行一次写操作:忙态 + 错误提示 + 成功后刷新。 */
2399
3161
  const run = useCallback(
@@ -2416,6 +3178,8 @@ window.__ModuleLoader__.load({
2416
3178
  )
2417
3179
 
2418
3180
  function submitTask() {
3181
+ // 上传中(计数 > 0)不提交:Enter 与按钮共用同一闸门,避免 note 里只有一半附件引用。
3182
+ if (isUploading(uploadingCount)) return
2419
3183
  const trimmedTitle = title.trim()
2420
3184
  if (trimmedTitle === '') {
2421
3185
  setNotice({ tone: 'warn', text: t('composer.empty') })
@@ -2425,6 +3189,12 @@ window.__ModuleLoader__.load({
2425
3189
  setNotice({ tone: 'warn', text: t('platform.workspaceRequired') })
2426
3190
  return
2427
3191
  }
3192
+ // 客户端预检:note 里不同附件引用 > 8 时给具体提示(与服务端 bad-request 文案同源,§2.1)。
3193
+ const limitText = noteAttachmentLimitText(t, note)
3194
+ if (limitText !== '') {
3195
+ setNotice({ tone: 'error', text: limitText })
3196
+ return
3197
+ }
2428
3198
  // 平台看板不绑会话:任务归属由所选工作区决定(cwd),派发由宿主自动挑会话。
2429
3199
  const payload = { title: trimmedTitle, cwd: workspaceCwd }
2430
3200
  if (note.trim() !== '') payload.note = note.trim()
@@ -2433,6 +3203,7 @@ window.__ModuleLoader__.load({
2433
3203
  setTitle('')
2434
3204
  setNote('')
2435
3205
  setShowNote(false)
3206
+ setAttachments([])
2436
3207
  })
2437
3208
  }
2438
3209
 
@@ -2488,10 +3259,48 @@ window.__ModuleLoader__.load({
2488
3259
  setNotice({ tone: 'warn', text: t('composer.empty') })
2489
3260
  return
2490
3261
  }
3262
+ // 编辑备注同样受单任务 8 个附件引用的限制(文本里手写的引用也算)。
3263
+ const limitText = noteAttachmentLimitText(t, editing.note)
3264
+ if (limitText !== '') {
3265
+ setNotice({ tone: 'error', text: limitText })
3266
+ return
3267
+ }
2491
3268
  updateTask(editing.id, { title: trimmedTitle, note: String(editing.note || '').trim() })
2492
3269
  setEditing(null)
2493
3270
  }
2494
3271
 
3272
+ /** 备注粘贴:有图片就走上传 + 短引用;没有图片返回 false(保持默认文本粘贴)。 */
3273
+ function onNotePaste(event) {
3274
+ return handleNotePaste(event, {
3275
+ t,
3276
+ setNote,
3277
+ setPending: setAttachments,
3278
+ beginUpload: () => setUploadingCount((value) => value + 1),
3279
+ endUpload: () => setUploadingCount((value) => Math.max(0, value - 1)),
3280
+ setNotice,
3281
+ })
3282
+ }
3283
+
3284
+ /** 移除一张待提交图片:缩略图与 note 里的引用一起删。 */
3285
+ function removePendingAttachment(id) {
3286
+ setAttachments((prev) => prev.filter((item) => item.id !== id))
3287
+ setNote((prev) => removeAttachmentRef(prev, id))
3288
+ }
3289
+
3290
+ /* ── 组长条动作(v0.2.0,与右栏看板同一套 RPC)──────────── */
3291
+ const leadActions = {
3292
+ bindMain: () => {
3293
+ if (currentSessionId === '') return
3294
+ run('lead:bind', () => callRpc('bind-main-session', { sessionId: currentSessionId }), t('lead.bindOk'))
3295
+ },
3296
+ clearMain: () => run('lead:clear', () => callRpc('clear-main-session', {}), t('lead.clearOk')),
3297
+ ensureLead: (cwd) => {
3298
+ if (typeof cwd !== 'string' || cwd === '') return
3299
+ run('lead:ensure', () => callRpc('ensure-workspace-lead', { cwd }), t('lead.ensureOk'))
3300
+ },
3301
+ openSession: (sessionIdToOpen) => openSessionById(sessionIdToOpen),
3302
+ }
3303
+
2495
3304
  // 组件身份保持稳定(同右栏看板):bind 存 ref、只改字段,pieces 只创建一次。
2496
3305
  const boardActions = {
2497
3306
  updateTask,
@@ -2499,7 +3308,10 @@ window.__ModuleLoader__.load({
2499
3308
  removeTask,
2500
3309
  requestDelete,
2501
3310
  isConfirmingDelete: (id) => confirmDeleteId === id,
2502
- openDetail: (task) => setDetailId(task.id),
3311
+ openDetail: (task) => {
3312
+ if (task) loadTaskAttachments(task, attachmentSourcesRef, setAttachmentSources)
3313
+ setDetailId(task.id)
3314
+ },
2503
3315
  openSession: (task) => openSessionById(task && (task.dispatchedSessionId || task.sessionId)),
2504
3316
  startEdit,
2505
3317
  saveEdit,
@@ -2511,23 +3323,32 @@ window.__ModuleLoader__.load({
2511
3323
  t,
2512
3324
  busy: '',
2513
3325
  editing: null,
2514
- now: 0,
2515
3326
  actions: boardActions,
2516
3327
  fallbackDispatchSessionId: '',
2517
3328
  lastDispatchTaskId: '',
3329
+ leads: null,
3330
+ leadRows: [],
3331
+ currentSessionId: '',
3332
+ leadActions,
2518
3333
  }
2519
3334
  }
2520
3335
  boardBindRef.current.t = t
2521
3336
  boardBindRef.current.busy = busy
2522
3337
  boardBindRef.current.editing = editing
2523
- boardBindRef.current.now = now
2524
3338
  boardBindRef.current.actions = boardActions
3339
+ boardBindRef.current.attachmentOf = (id) => attachmentSources[id] || null
2525
3340
  boardBindRef.current.fallbackDispatchSessionId = fallbackDispatchSessionId
2526
3341
  boardBindRef.current.lastDispatchTaskId = (poll && poll.lastDispatchTaskId) || ''
3342
+ // 组长条字段每次都刷新:leads 是运行时视图,revision 不变也会变。
3343
+ boardBindRef.current.leads = leads
3344
+ boardBindRef.current.leadRows = leadRows
3345
+ boardBindRef.current.currentSessionId = currentSessionId
3346
+ boardBindRef.current.leadActions = leadActions
2527
3347
  if (boardPiecesRef.current === null) boardPiecesRef.current = createBoardPieces(boardBindRef.current)
2528
3348
  const Banner = boardPiecesRef.current.Banner
2529
3349
  const Col = boardPiecesRef.current.Col
2530
3350
  const Detail = boardPiecesRef.current.Detail
3351
+ const LeadBar = boardPiecesRef.current.LeadBar
2531
3352
 
2532
3353
  const intervalText = fmtInterval(config.pollIntervalMs)
2533
3354
  const busyNow = busy !== ''
@@ -2591,13 +3412,13 @@ window.__ModuleLoader__.load({
2591
3412
  'select',
2592
3413
  {
2593
3414
  className: 'tb-select',
2594
- value: config.dispatchMode || 'new',
3415
+ value: dispatchModeOf(config),
2595
3416
  disabled: busyNow,
2596
3417
  title: t('dispatch.modeHint'),
2597
3418
  'aria-label': t('dispatch.mode'),
2598
3419
  onChange: (event) => setConfig({ dispatchMode: event.target.value }),
2599
3420
  },
2600
- ['new', 'creator', 'auto'].map((mode) => h('option', { key: mode, value: mode }, t('dispatch.mode.' + mode))),
3421
+ DISPATCH_MODES.map((mode) => h('option', { key: mode, value: mode }, t('dispatch.mode.' + mode))),
2601
3422
  ),
2602
3423
  ),
2603
3424
  h(
@@ -2623,6 +3444,7 @@ window.__ModuleLoader__.load({
2623
3444
  ),
2624
3445
  ),
2625
3446
 
3447
+ h(LeadBar, { key: 'leads' }),
2626
3448
  presetBanner ? h(Banner, { item: presetBanner }) : null,
2627
3449
  notice ? h(Banner, { item: notice, onClose: () => setNotice(null) }) : null,
2628
3450
  failures > 0 && error
@@ -2672,7 +3494,7 @@ window.__ModuleLoader__.load({
2672
3494
  {
2673
3495
  type: 'button',
2674
3496
  className: 'tb-btn tb-btn-primary',
2675
- disabled: busyNow || title.trim() === '' || workspaceRequired,
3497
+ disabled: submitBlocked({ busy: busyNow, uploading: uploadingCount, title, workspaceRequired }),
2676
3498
  onClick: submitTask,
2677
3499
  },
2678
3500
  t('composer.submit'),
@@ -2684,8 +3506,38 @@ window.__ModuleLoader__.load({
2684
3506
  placeholder: t('composer.note'),
2685
3507
  value: note,
2686
3508
  onChange: (event) => setNote(event.target.value),
3509
+ onPaste: onNotePaste,
2687
3510
  })
2688
3511
  : null,
3512
+ attachments.length > 0
3513
+ ? h(
3514
+ 'div',
3515
+ { className: 'tb-attach-strip' },
3516
+ attachments.map((item) =>
3517
+ h(
3518
+ 'div',
3519
+ { key: item.id, className: 'tb-attach-item' },
3520
+ h('img', {
3521
+ className: 'tb-attach-thumb',
3522
+ src: item.preview,
3523
+ alt: typeof item.name === 'string' ? item.name : '',
3524
+ title: t('composer.removeImage'),
3525
+ }),
3526
+ h(
3527
+ 'button',
3528
+ {
3529
+ type: 'button',
3530
+ className: 'tb-attach-remove',
3531
+ onClick: () => removePendingAttachment(item.id),
3532
+ 'aria-label': t('composer.removeImage'),
3533
+ title: t('composer.removeImage'),
3534
+ },
3535
+ '\u00d7',
3536
+ ),
3537
+ ),
3538
+ ),
3539
+ )
3540
+ : null,
2689
3541
  h(
2690
3542
  'div',
2691
3543
  { className: 'tb-composer-meta' },
@@ -2694,6 +3546,7 @@ window.__ModuleLoader__.load({
2694
3546
  { type: 'button', className: 'tb-linkbtn', onClick: () => setShowNote(!showNote), 'aria-expanded': showNote ? 'true' : 'false' },
2695
3547
  showNote ? t('composer.hideNote') : t('composer.addNote'),
2696
3548
  ),
3549
+ isUploading(uploadingCount) ? h('span', { className: 'tb-hint' }, t('composer.uploading')) : null,
2697
3550
  workspaceRequired ? h('span', { className: 'tb-hint' }, t('platform.workspaceRequired')) : null,
2698
3551
  ),
2699
3552
  ),
@@ -2875,6 +3728,30 @@ window.__ModuleLoader__.load({
2875
3728
  parseRichText,
2876
3729
  splitLooseSegments,
2877
3730
  renderInline,
3731
+ // v0.2.0 粘贴图片附件纯函数
3732
+ attachmentRef,
3733
+ attachmentIdsIn,
3734
+ insertAttachmentRef,
3735
+ removeAttachmentRef,
3736
+ clipboardImageFiles,
3737
+ splitPasteImages,
3738
+ isUploading,
3739
+ submitBlocked,
3740
+ noteAttachmentLimitText,
3741
+ maxPasteImages: MAX_PASTE_IMAGES,
3742
+ maxAttachmentBytes: MAX_ATTACHMENT_BYTES,
3743
+ maxAttachmentMb: MAX_ATTACHMENT_MB,
3744
+ maxAttachmentCache: MAX_ATTACHMENT_CACHE,
3745
+ maxNoteAttachments: MAX_NOTE_ATTACHMENTS,
3746
+ // v0.2.0 组长条 / 派发模式纯展示函数
3747
+ dispatchModes: DISPATCH_MODES,
3748
+ dispatchModeOf,
3749
+ leadStatusKey,
3750
+ leadTitleTail,
3751
+ leadMainRow,
3752
+ taskLeadLabel,
3753
+ taskWorkspaceCwds,
3754
+ workspaceLeadRows,
2878
3755
  }
2879
3756
 
2880
3757
  return module.exports