dsh-dispatch-board 0.2.3 → 0.2.5
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/README.md +9 -1
- package/lib/client.js +425 -36
- package/lib/index.js +578 -11
- package/package.json +1 -1
- package/presets/taskboard.patch.yml +11 -7
package/lib/client.js
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
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)
|
|
10
|
-
*
|
|
9
|
+
* (key: taskboard-platform) 页面;显示全部工作区的任务(卡片显示标题 + 一行工作区标签 +
|
|
10
|
+
* 操作按钮,备注 / 结论等信息都在详情浮层;右栏看板没有这行标签,工作区只在详情里看),
|
|
11
11
|
* 新建任务必须选工作区(add-task 传 cwd,不传 sessionId)。
|
|
12
12
|
*
|
|
13
13
|
* 数据通道:Host 在 webServer 注册的 /taskboard 前缀路由,经 Connection RPC 信封调用
|
|
@@ -127,8 +127,14 @@ window.__ModuleLoader__.load({
|
|
|
127
127
|
// ── 卡片 ───────────────────────────────────────────────────
|
|
128
128
|
// 卡片正文只有标题 + 操作按钮:note / result / lastError / meta 全部收进详情浮层,
|
|
129
129
|
// 看板上只靠标题辨认任务(完整信息点标题看详情)。
|
|
130
|
+
// 唯一例外:全局平台看板多一行工作区标签(.tb-card-workspace,v0.2.4),
|
|
131
|
+
// 右栏看板不传 workspaceLabel,卡片结构维持「标题 + 操作按钮」不变。
|
|
130
132
|
'.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}',
|
|
131
133
|
'.tb-card-title{font:var(--dsw-font-xxs-strong-12);font-weight:600;line-height:1.45;word-break:break-word}',
|
|
134
|
+
// 平台看板卡片上的一行工作区标签(v0.2.4):单行、超长省略,标题仍是第一眼信息。
|
|
135
|
+
// 只有全局看板的 Col 传入 workspaceLabel 时才渲染(右栏看板绑定单个工作区,不重复显示)。
|
|
136
|
+
'.tb-card-workspace{display:block;min-width:0;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font:var(--dsw-font-xxxs-11);color:var(--dsw-alias-label-tertiary);letter-spacing:0}',
|
|
137
|
+
'.tb-card-workspace[data-empty=true]{opacity:.65}',
|
|
132
138
|
'.tb-card-actions{display:flex;align-items:center;gap:4px;flex-wrap:wrap;padding-top:2px}',
|
|
133
139
|
'.tb-edit{display:flex;flex-direction:column;gap:6px}',
|
|
134
140
|
'.tb-edit-actions{display:flex;align-items:center;gap:6px;justify-content:flex-end}',
|
|
@@ -148,6 +154,23 @@ window.__ModuleLoader__.load({
|
|
|
148
154
|
'.tb-headbtn:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}',
|
|
149
155
|
'.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}',
|
|
150
156
|
'.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}',
|
|
157
|
+
// 左侧栏「任务看板」面板入口图标。宿主 .hHd-Xa_panelGlyph 是 inline-flex,会把 span.tb-icon
|
|
158
|
+
// 块级化;里面的内联 <svg> 按行盒基线排布,继承条目的 line-height:22px 后在行盒底部留下
|
|
159
|
+
// strut 下降部 → 字形比条目中心高 3px(真机 1280 宽实测:svg 中心 205 / 条目中心 208,而
|
|
160
|
+
// 同排宿主图标都是 208)。照 .tb-headbtn 的做法用 inline-flex + line-height:0 让盒子收紧到
|
|
161
|
+
// svg;position:relative 同时给角标组(t-89 的 .tb-badges)提供定位上下文——此前没有定位祖先时,
|
|
162
|
+
// 角标被钉到视口右上 / 右下角。
|
|
163
|
+
'.tb-icon{position:relative;display:inline-flex;align-items:center;justify-content:center;line-height:0}',
|
|
164
|
+
'.tb-icon>svg{display:block}',
|
|
165
|
+
// t-89:两枚角标并成一组(上=未完成、红=待你处理)。组的默认位置是图标右上角——侧栏收起
|
|
166
|
+
// 成 36px 图标列时宿主不渲染文字标签,这里就是降级位置;能量到宿主标签时
|
|
167
|
+
// (PlatformPanelIcon 量标签 rect),data-badge-anchor=label 把整组移到「任务看板」文字的
|
|
168
|
+
// 右上角:角标左缘 = 文字右缘 - 1px、上缘 = 文字上缘 - 6px,只压住字形右上角 1px 宽的一条。
|
|
169
|
+
'.tb-badges{position:absolute;top:-4px;right:-6px;display:inline-flex;flex-direction:column;align-items:flex-end;gap:2px;pointer-events:none}',
|
|
170
|
+
'.tb-icon[data-badge-anchor=label] .tb-badges{top:var(--tb-badge-y);left:var(--tb-badge-x);right:auto;flex-direction:row;align-items:center}',
|
|
171
|
+
// 侧栏图标只有 16/18px,14px 角标会盖住大半个字形:收成 border-box 的 12px;定位交给
|
|
172
|
+
// .tb-badges 排(这里 position:static 覆盖 .tb-badge 的绝对定位,宿主头部角标不受影响)。
|
|
173
|
+
'.tb-icon .tb-badge{position:static;box-sizing:border-box;min-width:12px;height:12px;padding:0 2px;font-size:9px}',
|
|
151
174
|
'.tb-tabtitle{display:inline-flex;align-items:center;gap:5px;min-width:0}',
|
|
152
175
|
// 右栏 tab 的关闭按钮由宿主 dockkit chrome 渲染(本插件只提供正文与 chip):宿主 CSS 会在
|
|
153
176
|
// tab active / focus-within 时强制显示关闭按钮。这里只收紧带本插件标题(.tb-tabtitle)的 tab——
|
|
@@ -175,6 +198,8 @@ window.__ModuleLoader__.load({
|
|
|
175
198
|
'.tb-detail{width:100%;max-width:900px;max-height:calc(100vh - 48px);display:flex;flex-direction:column;overflow:hidden;background:var(--dsw-alias-bg-base);border:1px solid var(--dsw-alias-border-l1);border-radius:14px;box-shadow:0 28px 72px rgba(0,0,0,.42);animation:tb-pop-in .14s ease-out}',
|
|
176
199
|
'@keyframes tb-pop-in{from{transform:translateY(6px) scale(.99);opacity:.6}to{transform:none;opacity:1}}',
|
|
177
200
|
'.tb-detail-head{display:flex;align-items:flex-start;gap:10px;padding:13px 16px 10px;border-bottom:1px solid var(--dsw-alias-border-l1);flex:0 0 auto}',
|
|
201
|
+
// 浮层内提示条(t-71):遮罩 z-index:9000 会盖住看板顶部横幅,跳转失败必须就近显示在浮层里。
|
|
202
|
+
'.tb-detail-banner{flex:0 0 auto;padding:10px 16px 0}',
|
|
178
203
|
'.tb-detail-headline{flex:1 1 auto;min-width:0;display:flex;flex-direction:column;gap:6px}',
|
|
179
204
|
'.tb-detail-badges{display:flex;flex-wrap:wrap;align-items:center;gap:5px}',
|
|
180
205
|
'.tb-detail-title{margin:0;font:var(--dsw-font-sm-13);font-weight:600;line-height:1.4;color:var(--dsw-alias-label-primary);word-break:break-word}',
|
|
@@ -349,6 +374,7 @@ window.__ModuleLoader__.load({
|
|
|
349
374
|
'.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}',
|
|
350
375
|
'.tb-card:hover{box-shadow:var(--tb-shadow-2);border-color:var(--tb-hairline);transform:translateY(-1px)}',
|
|
351
376
|
'.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}',
|
|
377
|
+
'.tb-card-workspace{color:var(--tb-text-3);font-size:10px;line-height:1.45}',
|
|
352
378
|
'.tb-empty{color:var(--tb-text-3);font-size:11px;padding:12px 6px;text-align:center;border:0;background:transparent}',
|
|
353
379
|
'.tb-foot{color:var(--tb-text-3);font-size:10px;padding-top:2px;border-top:1px solid var(--tb-hairline-soft)}',
|
|
354
380
|
'.tb-foot code{background:var(--dsw-alias-bg-skeleton);border-radius:5px;padding:1px 5px;font-size:9.5px}',
|
|
@@ -502,6 +528,9 @@ window.__ModuleLoader__.load({
|
|
|
502
528
|
'card.deleteConfirmShort': '确认删除',
|
|
503
529
|
'card.detail': '详情',
|
|
504
530
|
'card.openChat': '对话',
|
|
531
|
+
// v0.2.4:点「对话」失败不再静默(服务缺失 / 目标会话已关闭或不存在)。
|
|
532
|
+
'openSession.failed': '无法打开对话:会话 {session} 已关闭或不存在',
|
|
533
|
+
'openSession.unavailable': '无法打开对话:会话导航服务未就绪,请稍后重试',
|
|
505
534
|
'detail.sessions': '关联对话',
|
|
506
535
|
'detail.creatorSession': '发起对话',
|
|
507
536
|
'detail.runSession': '执行对话',
|
|
@@ -685,6 +714,9 @@ window.__ModuleLoader__.load({
|
|
|
685
714
|
'card.deleteConfirmShort': 'Confirm delete',
|
|
686
715
|
'card.detail': 'Details',
|
|
687
716
|
'card.openChat': 'Chat',
|
|
717
|
+
// Unreleased (0.2.4 candidate): a failed 对话 click must never be silent.
|
|
718
|
+
'openSession.failed': 'Cannot open conversation: session {session} is closed or unavailable',
|
|
719
|
+
'openSession.unavailable': 'Cannot open conversation: session navigation is not ready yet, please retry',
|
|
688
720
|
'detail.sessions': 'Linked conversations',
|
|
689
721
|
'detail.creatorSession': 'Created in',
|
|
690
722
|
'detail.runSession': 'Dispatched to',
|
|
@@ -939,6 +971,23 @@ window.__ModuleLoader__.load({
|
|
|
939
971
|
return baseName(path)
|
|
940
972
|
}
|
|
941
973
|
|
|
974
|
+
/** 卡片工作区标签的兜底占位:任务没有 cwd(老任务 / 没归属)时显示。 */
|
|
975
|
+
const WORKSPACE_LABEL_NONE = '\u2014'
|
|
976
|
+
|
|
977
|
+
/**
|
|
978
|
+
* 平台看板卡片上的一行工作区标签(v0.2.4):只给**全局看板**用,
|
|
979
|
+
* 右栏看板不调用(那块看板绑定单个工作区,再标一遍是重复信息)。
|
|
980
|
+
* - `cwd` 命中 `snapshot.workspaces` → 用该工作区的 `title`;
|
|
981
|
+
* - `cwd` 未注册 / `title` 为空 → 回退路径尾段 `baseName(cwd)`(与下拉选项同一规则);
|
|
982
|
+
* - `cwd` 为空 / 非字符串 → `—` 占位(不抛错,渲染里不会出现 undefined)。
|
|
983
|
+
*/
|
|
984
|
+
function taskWorkspaceLabel(workspaces, task) {
|
|
985
|
+
const cwd = task && typeof task.cwd === 'string' ? task.cwd : ''
|
|
986
|
+
if (cwd === '') return WORKSPACE_LABEL_NONE
|
|
987
|
+
const label = workspaceTitleOf(workspaces, cwd)
|
|
988
|
+
return label !== '' ? label : WORKSPACE_LABEL_NONE
|
|
989
|
+
}
|
|
990
|
+
|
|
942
991
|
/**
|
|
943
992
|
* 右栏「本工作区看板」的过滤:
|
|
944
993
|
* - cwd 与当前工作区相同的任务;或
|
|
@@ -1658,6 +1707,68 @@ window.__ModuleLoader__.load({
|
|
|
1658
1707
|
return text === known ? error.message || t('error.internal') : text
|
|
1659
1708
|
}
|
|
1660
1709
|
|
|
1710
|
+
/* 侧栏角标贴「任务看板」文字(t-89)。
|
|
1711
|
+
*
|
|
1712
|
+
* 宿主契约(dsh-client-ui-sidebar `SidebarPanelIconOwnerProps`)只给插件 { size, active },
|
|
1713
|
+
* 没有 badge / count / trailing 之类的挂载点:`sidebar.panellist` 的行按钮(button[aria-label]
|
|
1714
|
+
* = 面板名)由宿主渲染,图标在 `span.panelGlyph` 里,文字标签是同一按钮里的另一个子节点
|
|
1715
|
+
* `span.panelTitle`,两者是同级兄弟。所以「角标贴文字右上角」只能自己量:
|
|
1716
|
+
* 把标签 rect 换算成相对 .tb-icon 的偏移,写进 CSS 变量,整组角标绝对定位到 .tb-icon 上。
|
|
1717
|
+
* 量不到标签(侧栏收起成 36px 图标列 / 宿主结构变化 / 元素不在文档里)→ 返回 null,
|
|
1718
|
+
* CSS 退回图标右上角(data-badge-anchor=icon),不报错、不跑位。
|
|
1719
|
+
*/
|
|
1720
|
+
const BADGE_LABEL_GAP_X = 1
|
|
1721
|
+
const BADGE_LABEL_LIFT_Y = 6
|
|
1722
|
+
|
|
1723
|
+
/**
|
|
1724
|
+
* 纯函数:标签 rect → 角标组左上角(相对 .tb-icon 左上角,px)。
|
|
1725
|
+
* @param {{right:number, top:number}} labelRect 宿主标签节点的 getBoundingClientRect()
|
|
1726
|
+
* @param {{left:number, top:number}} iconRect 本插件 .tb-icon 的 getBoundingClientRect()
|
|
1727
|
+
* @returns {{left:number, top:number}}
|
|
1728
|
+
*/
|
|
1729
|
+
function labelBadgeAnchor(labelRect, iconRect) {
|
|
1730
|
+
const round = (n) => Math.round(n * 100) / 100
|
|
1731
|
+
return {
|
|
1732
|
+
left: round(labelRect.right - iconRect.left - BADGE_LABEL_GAP_X),
|
|
1733
|
+
top: round(labelRect.top - iconRect.top - BADGE_LABEL_LIFT_Y),
|
|
1734
|
+
}
|
|
1735
|
+
}
|
|
1736
|
+
|
|
1737
|
+
/**
|
|
1738
|
+
* 宿主行里的文字标签节点(不是包着图标的那一支、且有文字)。
|
|
1739
|
+
* 先认宿主 CSS Module 类名里的 `panelTitle`(rc.1 / rc.2 都是 `*_panelTitle`),
|
|
1740
|
+
* 识别不到再按「不含图标 + 有文字」兜底;宿主改结构时最坏返回 null(角标退回图标角)。
|
|
1741
|
+
* @param {Element|null} row 宿主行按钮
|
|
1742
|
+
* @param {Element|null} iconEl 本插件 .tb-icon
|
|
1743
|
+
* @returns {Element|null}
|
|
1744
|
+
*/
|
|
1745
|
+
function hostLabelNode(row, iconEl) {
|
|
1746
|
+
if (!row || !iconEl || !row.children) return null
|
|
1747
|
+
const kids = Array.prototype.slice.call(row.children)
|
|
1748
|
+
const hasText = (node) => !!node && typeof node.textContent === 'string' && node.textContent.trim() !== ''
|
|
1749
|
+
const titled = kids.find((node) => /panelTitle/.test(String(node.className || '')) && hasText(node))
|
|
1750
|
+
if (titled) return titled
|
|
1751
|
+
return kids.find((node) => !(typeof node.contains === 'function' && node.contains(iconEl)) && hasText(node)) || null
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1754
|
+
/** 量一次角标锚点;拿不到标签 / 元素不在文档里(rect 全 0)返回 null。 */
|
|
1755
|
+
function measureLabelBadgeAnchor(iconEl) {
|
|
1756
|
+
if (!iconEl || typeof iconEl.getBoundingClientRect !== 'function') return null
|
|
1757
|
+
const row = typeof iconEl.closest === 'function' ? iconEl.closest('button') : null
|
|
1758
|
+
const label = hostLabelNode(row, iconEl)
|
|
1759
|
+
if (!label || typeof label.getBoundingClientRect !== 'function') return null
|
|
1760
|
+
const iconRect = iconEl.getBoundingClientRect()
|
|
1761
|
+
const labelRect = label.getBoundingClientRect()
|
|
1762
|
+
if (!iconRect || !labelRect || !(labelRect.width > 0) || !(labelRect.height > 0)) return null
|
|
1763
|
+
return labelBadgeAnchor(labelRect, iconRect)
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
/** 两次测量的角标锚点是否等价(亚像素抖动不触发重渲染)。 */
|
|
1767
|
+
function sameBadgeAnchor(a, b) {
|
|
1768
|
+
if (!a || !b) return a === b
|
|
1769
|
+
return Math.abs(a.left - b.left) < 0.5 && Math.abs(a.top - b.top) < 0.5
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1661
1772
|
/* ══════════════════════════════════════════════════════════════
|
|
1662
1773
|
* 插件主体
|
|
1663
1774
|
* ══════════════════════════════════════════════════════════════ */
|
|
@@ -1894,18 +2005,53 @@ window.__ModuleLoader__.load({
|
|
|
1894
2005
|
// 用会话 header / 右栏看板渲染时记下的值当「当前对话」;拿不到就禁用主会话绑定并提示。
|
|
1895
2006
|
let lastConversationSessionId = ''
|
|
1896
2007
|
|
|
1897
|
-
/**
|
|
2008
|
+
/**
|
|
2009
|
+
* 在看板里直接跳到某个会话(发起对话 / 执行对话 / 组长对话)。
|
|
2010
|
+
* 返回 `{ ok, reason, sessionId }`,调用方据此给用户**可见**反馈——跳转失败绝不静默:
|
|
2011
|
+
* - `invalid`:没有目标 id;
|
|
2012
|
+
* - `unavailable`:宿主没注入 `uiWorkspace`(或它没有 `openSession`);
|
|
2013
|
+
* - `error`:`openSession` 同步抛错。典型是 `sessions.retain: unknown session <id>`
|
|
2014
|
+
* (目标会话已被移除 / 客户端此刻解析不到),也可能来自会话控制器已销毁。
|
|
2015
|
+
* `uiWorkspace.openSession` 是同步 void:能抛错就说明这次导航没有发生。
|
|
2016
|
+
*/
|
|
1898
2017
|
function openSessionById(sessionId) {
|
|
1899
|
-
if (typeof sessionId !== 'string' || sessionId === '') return
|
|
2018
|
+
if (typeof sessionId !== 'string' || sessionId === '') return { ok: false, reason: 'invalid', sessionId: '' }
|
|
1900
2019
|
if (!uiWorkspaceService || typeof uiWorkspaceService.openSession !== 'function') {
|
|
1901
2020
|
console.warn('[dsh-dispatch-board] uiWorkspace 不可用,无法跳转会话:' + sessionId)
|
|
1902
|
-
return
|
|
2021
|
+
return { ok: false, reason: 'unavailable', sessionId }
|
|
1903
2022
|
}
|
|
1904
2023
|
try {
|
|
1905
2024
|
uiWorkspaceService.openSession(sessionId)
|
|
2025
|
+
return { ok: true, sessionId }
|
|
1906
2026
|
} catch (error) {
|
|
1907
2027
|
console.warn('[dsh-dispatch-board] 跳转会话失败:' + describeErr(error))
|
|
2028
|
+
return { ok: false, reason: 'error', sessionId, error }
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
|
|
2032
|
+
/**
|
|
2033
|
+
* 按顺序尝试多个候选会话(worker → 组长 → 发起 → poll 兜底):
|
|
2034
|
+
* 第一个能打开的立即返回;`unavailable` 时后面的目标必然同样打不开,直接停。
|
|
2035
|
+
*/
|
|
2036
|
+
function openFirstAvailable(candidates) {
|
|
2037
|
+
const list = Array.isArray(candidates) ? candidates : []
|
|
2038
|
+
let last = { ok: false, reason: 'invalid', sessionId: '' }
|
|
2039
|
+
for (const sessionId of list) {
|
|
2040
|
+
if (typeof sessionId !== 'string' || sessionId === '') continue
|
|
2041
|
+
const result = openSessionById(sessionId)
|
|
2042
|
+
if (result.ok) return result
|
|
2043
|
+
last = result
|
|
2044
|
+
if (result.reason === 'unavailable') break
|
|
1908
2045
|
}
|
|
2046
|
+
return last
|
|
2047
|
+
}
|
|
2048
|
+
|
|
2049
|
+
/** 跳转失败的顶部提示文案(两块看板共用;`t` 由组件传入,保持纯函数可测)。 */
|
|
2050
|
+
function sessionFailureText(t, result, candidates) {
|
|
2051
|
+
if (result && result.reason === 'unavailable') return t('openSession.unavailable')
|
|
2052
|
+
const list = Array.isArray(candidates) ? candidates : []
|
|
2053
|
+
const first = list.find((id) => typeof id === 'string' && id !== '') || ''
|
|
2054
|
+
return t('openSession.failed', { session: shortSession(first) })
|
|
1909
2055
|
}
|
|
1910
2056
|
|
|
1911
2057
|
function openBoard(retry = 0) {
|
|
@@ -2128,15 +2274,28 @@ window.__ModuleLoader__.load({
|
|
|
2128
2274
|
/**
|
|
2129
2275
|
* 任务关联的会话(卡片「对话」按钮的跳转目标),优先级:
|
|
2130
2276
|
* worker 子会话(真正执行任务的对话)→ 组长会话(dispatchedSessionId)→ 发起对话(sessionId)
|
|
2131
|
-
* → 老 Host 的 poll 兜底(doing
|
|
2277
|
+
* → 老 Host 的 poll 兜底(doing)。
|
|
2278
|
+
*
|
|
2279
|
+
* 返回**去重后的候选链**(v0.2.4):worker 子会话是子 Agent 会话,客户端未必解析得到
|
|
2280
|
+
* (侧栏隐藏、依赖父会话 catalog),打不开时不能连累整次点击——调用方按顺序试到第一个能打开的。
|
|
2132
2281
|
*/
|
|
2282
|
+
function sessionCandidatesOf(task) {
|
|
2283
|
+
if (!task) return []
|
|
2284
|
+
const out = []
|
|
2285
|
+
const push = (value) => {
|
|
2286
|
+
if (typeof value === 'string' && value !== '' && out.indexOf(value) < 0) out.push(value)
|
|
2287
|
+
}
|
|
2288
|
+
push(workerSessionOf(task))
|
|
2289
|
+
push(task.dispatchedSessionId)
|
|
2290
|
+
push(task.sessionId)
|
|
2291
|
+
push(pollFallbackSessionOf(task))
|
|
2292
|
+
return out
|
|
2293
|
+
}
|
|
2294
|
+
|
|
2295
|
+
/** 卡片「对话」按钮显示的目标(候选链首个);没有关联会话返回空串(不渲染按钮)。 */
|
|
2133
2296
|
function sessionOf(task) {
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
if (worker !== '') return worker
|
|
2137
|
-
if (typeof task.dispatchedSessionId === 'string' && task.dispatchedSessionId !== '') return task.dispatchedSessionId
|
|
2138
|
-
if (typeof task.sessionId === 'string' && task.sessionId !== '') return task.sessionId
|
|
2139
|
-
return pollFallbackSessionOf(task)
|
|
2297
|
+
const candidates = sessionCandidatesOf(task)
|
|
2298
|
+
return candidates.length > 0 ? candidates[0] : ''
|
|
2140
2299
|
}
|
|
2141
2300
|
|
|
2142
2301
|
/* ── 子组件 ───────────────────────────────────────────── */
|
|
@@ -2153,6 +2312,25 @@ window.__ModuleLoader__.load({
|
|
|
2153
2312
|
)
|
|
2154
2313
|
}
|
|
2155
2314
|
|
|
2315
|
+
/**
|
|
2316
|
+
* 平台看板卡片上的一行工作区标签(v0.2.4):纯展示,不调 hooks。
|
|
2317
|
+
* 文本由调用方算好(`taskWorkspaceLabel`);`title` 兜完整工作区路径(过长时单行省略),
|
|
2318
|
+
* `data-empty` 让「没有 cwd」的占位(—)弱化一点。右栏看板不传 label → 整块不渲染。
|
|
2319
|
+
*/
|
|
2320
|
+
function WorkspaceTag(props) {
|
|
2321
|
+
const label = props && typeof props.label === 'string' ? props.label : ''
|
|
2322
|
+
if (label === '') return null
|
|
2323
|
+
return h(
|
|
2324
|
+
'div',
|
|
2325
|
+
{
|
|
2326
|
+
className: 'tb-card-workspace',
|
|
2327
|
+
'data-empty': props.empty === true ? 'true' : 'false',
|
|
2328
|
+
title: typeof props.path === 'string' && props.path !== '' ? props.path : undefined,
|
|
2329
|
+
},
|
|
2330
|
+
label,
|
|
2331
|
+
)
|
|
2332
|
+
}
|
|
2333
|
+
|
|
2156
2334
|
function Col(props) {
|
|
2157
2335
|
const t = bind.t
|
|
2158
2336
|
const busy = bind.busy
|
|
@@ -2160,6 +2338,8 @@ window.__ModuleLoader__.load({
|
|
|
2160
2338
|
const status = props.status
|
|
2161
2339
|
const list = props.tasks
|
|
2162
2340
|
const compact = props.compact === true
|
|
2341
|
+
// 只有平台看板传 workspaceLabel((task) => 展示名);右栏看板不传 → 卡片不带工作区标签。
|
|
2342
|
+
const workspaceLabelOf = typeof props.workspaceLabel === 'function' ? props.workspaceLabel : null
|
|
2163
2343
|
return h(
|
|
2164
2344
|
'section',
|
|
2165
2345
|
{
|
|
@@ -2203,7 +2383,17 @@ window.__ModuleLoader__.load({
|
|
|
2203
2383
|
),
|
|
2204
2384
|
list.length === 0
|
|
2205
2385
|
? h('div', { className: 'tb-empty' }, t('column.empty.' + status))
|
|
2206
|
-
: h(
|
|
2386
|
+
: h(
|
|
2387
|
+
'div',
|
|
2388
|
+
{ className: 'tb-cards' },
|
|
2389
|
+
list.map((task) =>
|
|
2390
|
+
h(Card, {
|
|
2391
|
+
key: task.id,
|
|
2392
|
+
task,
|
|
2393
|
+
workspaceLabel: workspaceLabelOf ? workspaceLabelOf(task) : '',
|
|
2394
|
+
}),
|
|
2395
|
+
),
|
|
2396
|
+
),
|
|
2207
2397
|
)
|
|
2208
2398
|
}
|
|
2209
2399
|
|
|
@@ -2256,6 +2446,9 @@ window.__ModuleLoader__.load({
|
|
|
2256
2446
|
const t = bind.t
|
|
2257
2447
|
const list = props && Array.isArray(props.tasks) ? props.tasks : []
|
|
2258
2448
|
const actions = bind.actions
|
|
2449
|
+
// 第五列也是全局视角(只有平台看板渲染它):同样显示工作区标签;
|
|
2450
|
+
// 右栏的「待你处理」是顶部条(.tb-needs-item,不是卡片),不受影响。
|
|
2451
|
+
const workspaceLabelOf = props && typeof props.workspaceLabel === 'function' ? props.workspaceLabel : null
|
|
2259
2452
|
return h(
|
|
2260
2453
|
'section',
|
|
2261
2454
|
{
|
|
@@ -2299,6 +2492,11 @@ window.__ModuleLoader__.load({
|
|
|
2299
2492
|
task.title,
|
|
2300
2493
|
),
|
|
2301
2494
|
h('div', { className: 'tb-needs-card-q', title: task.question || '' }, task.question || ''),
|
|
2495
|
+
h(WorkspaceTag, {
|
|
2496
|
+
label: workspaceLabelOf ? workspaceLabelOf(task) : '',
|
|
2497
|
+
empty: !(typeof task.cwd === 'string' && task.cwd !== ''),
|
|
2498
|
+
path: typeof task.cwd === 'string' ? task.cwd : '',
|
|
2499
|
+
}),
|
|
2302
2500
|
h(
|
|
2303
2501
|
'div',
|
|
2304
2502
|
{ className: 'tb-card-actions' },
|
|
@@ -2321,6 +2519,9 @@ window.__ModuleLoader__.load({
|
|
|
2321
2519
|
const actions = bind.actions
|
|
2322
2520
|
const task = props.task
|
|
2323
2521
|
const status = task.status
|
|
2522
|
+
// 工作区标签(v0.2.4):只有平台看板的 Col 传值;右栏看板传空串 → 不渲染。
|
|
2523
|
+
const workspaceLabel = typeof props.workspaceLabel === 'string' ? props.workspaceLabel : ''
|
|
2524
|
+
const hasCwd = typeof task.cwd === 'string' && task.cwd !== ''
|
|
2324
2525
|
const isEditing = editing !== null && editing.id === task.id
|
|
2325
2526
|
const busyKey = 'update:' + task.id
|
|
2326
2527
|
// 行内二次确认:不用 window.confirm(浏览器可能已勾选「阻止此页面的其它对话框」,那样确认永远为 false,
|
|
@@ -2387,16 +2588,19 @@ window.__ModuleLoader__.load({
|
|
|
2387
2588
|
cardActions.push([confirmingDelete ? 'deleteConfirmShort' : 'delete', requestDelete, false])
|
|
2388
2589
|
}
|
|
2389
2590
|
|
|
2390
|
-
// 卡片只留标题 + 操作按钮:note / result / lastError / id /
|
|
2591
|
+
// 卡片只留标题 + 操作按钮:note / result / lastError / id / 时间 /
|
|
2391
2592
|
// 执行者 / 组长这些背景信息都在详情浮层里看(点标题或「详情」)。
|
|
2593
|
+
// 唯一例外是全局平台看板多一行工作区标签(WorkspaceTag,由 props.workspaceLabel 控制)。
|
|
2392
2594
|
// 少这一整段后卡片高度由内容决定(.tb-card-fixed 的标题固定 2 行高度 +
|
|
2393
2595
|
// 标题/按钮之间只留 gap,不再用整卡 min-height + 操作行 margin-top:auto 撑空行)。
|
|
2394
2596
|
|
|
2395
2597
|
cardActions.unshift(['detail', () => actions.openDetail(task), false])
|
|
2396
2598
|
// 卡片「对话」优先 worker 子会话(真正干活的对话),其次组长 / 发起对话;title 用实际目标 id 便于辨认。
|
|
2599
|
+
// 点击走 actions.openChat(task):worker 打不开时自动回退组长 / 发起会话,全部失败出顶部提示(不静默)。
|
|
2397
2600
|
const cardSessionId = sessionOf(task)
|
|
2398
2601
|
if (cardSessionId !== '') {
|
|
2399
|
-
|
|
2602
|
+
const openChatAction = () => (typeof actions.openChat === 'function' ? actions.openChat(task) : actions.openSession(cardSessionId))
|
|
2603
|
+
cardActions.push(['openChat', openChatAction, false, cardSessionId])
|
|
2400
2604
|
}
|
|
2401
2605
|
|
|
2402
2606
|
return h(
|
|
@@ -2420,6 +2624,9 @@ window.__ModuleLoader__.load({
|
|
|
2420
2624
|
},
|
|
2421
2625
|
task.title,
|
|
2422
2626
|
),
|
|
2627
|
+
// 工作区标签放在标题与操作行之间(副标题位):不挤标题的 2 行高度,
|
|
2628
|
+
// 单行省略;cwd 为空时显示「—」占位。
|
|
2629
|
+
h(WorkspaceTag, { label: workspaceLabel, empty: !hasCwd, path: hasCwd ? task.cwd : '' }),
|
|
2423
2630
|
h(
|
|
2424
2631
|
'div',
|
|
2425
2632
|
{ className: 'tb-card-actions' },
|
|
@@ -2537,6 +2744,11 @@ window.__ModuleLoader__.load({
|
|
|
2537
2744
|
'\u00d7',
|
|
2538
2745
|
),
|
|
2539
2746
|
),
|
|
2747
|
+
// t-71:浮层内会话按钮失败时,提示条渲染在浮层内部——`.tb-detail-mask` 是 z-index:9000
|
|
2748
|
+
// 的全屏遮罩,看板顶部的 notice 横幅会被它盖住,用户看起来仍是「点了没反应」。
|
|
2749
|
+
props.notice && props.notice.text
|
|
2750
|
+
? h('div', { className: 'tb-detail-banner' }, h(Banner, { item: props.notice, onClose: props.onDismissNotice }))
|
|
2751
|
+
: null,
|
|
2540
2752
|
h(
|
|
2541
2753
|
'div',
|
|
2542
2754
|
{ className: 'tb-detail-body' },
|
|
@@ -2866,7 +3078,7 @@ window.__ModuleLoader__.load({
|
|
|
2866
3078
|
return h('div', { className: 'tb-leads', role: 'group', 'aria-label': t('lead.barLabel') }, cells)
|
|
2867
3079
|
}
|
|
2868
3080
|
|
|
2869
|
-
return { Banner, Col, Detail, LeadBar, NeedsBanner, NeedsColumn }
|
|
3081
|
+
return { Banner, Col, Detail, LeadBar, NeedsBanner, NeedsColumn, sessionCandidatesOf }
|
|
2870
3082
|
}
|
|
2871
3083
|
|
|
2872
3084
|
/* ── 看板页 ─────────────────────────────────────────────── */
|
|
@@ -2897,6 +3109,8 @@ window.__ModuleLoader__.load({
|
|
|
2897
3109
|
const [busy, setBusy] = useState('')
|
|
2898
3110
|
const [confirmDeleteId, setConfirmDeleteId] = useState(null)
|
|
2899
3111
|
const [detailId, setDetailId] = useState(null)
|
|
3112
|
+
// t-71:详情浮层内的会话跳转失败提示(渲染在浮层内部;顶部横幅会被 .tb-detail-mask 遮住)。
|
|
3113
|
+
const [detailNotice, setDetailNotice] = useState(null)
|
|
2900
3114
|
// v0.2.2「待你处理」:回答草稿 / 行内错误(详情浮层只读,不持有 state)。
|
|
2901
3115
|
const [answerDraft, setAnswerDraft] = useState('')
|
|
2902
3116
|
const [answerError, setAnswerError] = useState('')
|
|
@@ -3180,6 +3394,43 @@ window.__ModuleLoader__.load({
|
|
|
3180
3394
|
setNote((prev) => removeAttachmentRef(prev, id))
|
|
3181
3395
|
}
|
|
3182
3396
|
|
|
3397
|
+
/* ── 跳到关联会话(v0.2.4):失败不再静默 ─────────── */
|
|
3398
|
+
/**
|
|
3399
|
+
* 统一反馈:能打开就跳转,打不开就出 warn 横幅(`setNotice`,§5.2)。
|
|
3400
|
+
* 返回底层结果,便于把纯逻辑与 UI 拆开测试。
|
|
3401
|
+
*
|
|
3402
|
+
* t-71:浮层开着时把提示交给浮层(`detailNotice`)渲染——`.tb-detail-mask` 是 z-index:9000
|
|
3403
|
+
* 的全屏遮罩,看板顶部横幅在它下面,用户看不见。成功跳转顺带清掉上一次的会话失败提示;
|
|
3404
|
+
* `kind:'session'` 标记保证只清自己设的提示,不误清「派发成功」「已归档」等其它通知。
|
|
3405
|
+
*/
|
|
3406
|
+
function reportSessionFailure(result, candidates) {
|
|
3407
|
+
if (result && result.ok) {
|
|
3408
|
+
setNotice((prev) => (prev && prev.kind === 'session' ? null : prev))
|
|
3409
|
+
setDetailNotice((prev) => (prev && prev.kind === 'session' ? null : prev))
|
|
3410
|
+
return result
|
|
3411
|
+
}
|
|
3412
|
+
const item = { tone: 'warn', text: sessionFailureText(t, result, candidates), kind: 'session' }
|
|
3413
|
+
if (detailId !== null) {
|
|
3414
|
+
setDetailNotice(item)
|
|
3415
|
+
setNotice((prev) => (prev && prev.kind === 'session' ? null : prev))
|
|
3416
|
+
} else {
|
|
3417
|
+
setNotice(item)
|
|
3418
|
+
}
|
|
3419
|
+
return result
|
|
3420
|
+
}
|
|
3421
|
+
|
|
3422
|
+
/** 单个会话 id 的跳转(组长条 / 详情「关联对话」用)。 */
|
|
3423
|
+
function openSessionAction(sessionId) {
|
|
3424
|
+
return reportSessionFailure(openSessionById(sessionId), [sessionId])
|
|
3425
|
+
}
|
|
3426
|
+
|
|
3427
|
+
/** 任务卡片的「对话」:按候选链(worker → 组长 → 发起 → poll 兜底)试到第一个能打开的。 */
|
|
3428
|
+
function openChatAction(task) {
|
|
3429
|
+
const pieces = boardPiecesRef.current
|
|
3430
|
+
const candidates = pieces && typeof pieces.sessionCandidatesOf === 'function' ? pieces.sessionCandidatesOf(task) : []
|
|
3431
|
+
return reportSessionFailure(openFirstAvailable(candidates), candidates)
|
|
3432
|
+
}
|
|
3433
|
+
|
|
3183
3434
|
/* ── 组长条动作(v0.2.0)────────────────────────────────── */
|
|
3184
3435
|
// 三个新 RPC:bind-main-session {sessionId} / clear-main-session {} / ensure-workspace-lead {cwd}。
|
|
3185
3436
|
// 失败走 run() 的顶部错误条(errorText),不乐观更新、不崩。
|
|
@@ -3193,7 +3444,7 @@ window.__ModuleLoader__.load({
|
|
|
3193
3444
|
if (typeof cwd !== 'string' || cwd === '') return
|
|
3194
3445
|
run('lead:ensure', () => callRpc('ensure-workspace-lead', { cwd }), t('lead.ensureOk'))
|
|
3195
3446
|
},
|
|
3196
|
-
openSession: (sessionIdToOpen) =>
|
|
3447
|
+
openSession: (sessionIdToOpen) => openSessionAction(sessionIdToOpen),
|
|
3197
3448
|
}
|
|
3198
3449
|
|
|
3199
3450
|
/* ── 子组件(与平台看板共用)──────────────────────────── */
|
|
@@ -3210,16 +3461,19 @@ window.__ModuleLoader__.load({
|
|
|
3210
3461
|
// v0.2.2:换一条任务就清掉上一条的回答草稿 / 错误,避免答案串台。
|
|
3211
3462
|
setAnswerDraft('')
|
|
3212
3463
|
setAnswerError('')
|
|
3464
|
+
// t-71:上一条任务的会话失败提示也不带到新浮层。
|
|
3465
|
+
setDetailNotice(null)
|
|
3213
3466
|
setDetailId(task.id)
|
|
3214
3467
|
},
|
|
3215
3468
|
// 「对话」按钮传目标会话 id;仍兼容传任务对象的旧调用(取 dispatched → creator)。
|
|
3469
|
+
// 失败(目标会话已关闭 / 服务缺失)出 warn 提示,不再只 console.warn(v0.2.4)。
|
|
3216
3470
|
openSession: (target) => {
|
|
3217
|
-
if (typeof target === 'string')
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
}
|
|
3221
|
-
openSessionById(target && (target.dispatchedSessionId || target.sessionId))
|
|
3471
|
+
if (typeof target === 'string') return openSessionAction(target)
|
|
3472
|
+
const candidates = target ? [target.dispatchedSessionId, target.sessionId] : []
|
|
3473
|
+
return reportSessionFailure(openFirstAvailable(candidates), candidates)
|
|
3222
3474
|
},
|
|
3475
|
+
// 卡片「对话」专用:worker 打不开时回退组长 / 发起会话(候选链见 sessionCandidatesOf)。
|
|
3476
|
+
openChat: (task) => openChatAction(task),
|
|
3223
3477
|
startEdit,
|
|
3224
3478
|
saveEdit,
|
|
3225
3479
|
setEditing,
|
|
@@ -3509,14 +3763,19 @@ window.__ModuleLoader__.load({
|
|
|
3509
3763
|
task: detailTask,
|
|
3510
3764
|
onClose: () => {
|
|
3511
3765
|
setDetailId(null)
|
|
3766
|
+
setDetailNotice(null)
|
|
3512
3767
|
setAnswerDraft('')
|
|
3513
3768
|
setAnswerError('')
|
|
3514
3769
|
},
|
|
3515
3770
|
onStatus: (status) => {
|
|
3516
3771
|
setDetailId(null)
|
|
3772
|
+
setDetailNotice(null)
|
|
3517
3773
|
updateTask(detailTask.id, { status })
|
|
3518
3774
|
},
|
|
3519
|
-
|
|
3775
|
+
// t-71:浮层内会话按钮失败时,提示条渲染在浮层内部(遮罩盖住顶部的 notice 横幅)。
|
|
3776
|
+
notice: detailNotice,
|
|
3777
|
+
onDismissNotice: () => setDetailNotice(null),
|
|
3778
|
+
openSession: (sessionId) => openSessionAction(sessionId),
|
|
3520
3779
|
})
|
|
3521
3780
|
: null,
|
|
3522
3781
|
)
|
|
@@ -3530,6 +3789,9 @@ window.__ModuleLoader__.load({
|
|
|
3530
3789
|
const [openCount, setOpenCount] = useState(-1)
|
|
3531
3790
|
// v0.2.2(§1.9):待你处理数量单独一个红色角标。
|
|
3532
3791
|
const [needsCount, setNeedsCount] = useState(-1)
|
|
3792
|
+
const iconRef = useRef(null)
|
|
3793
|
+
// t-89:角标组相对 .tb-icon 的偏移(null = 还没量到宿主标签 → CSS 退回图标右上角)。
|
|
3794
|
+
const [badgeAnchor, setBadgeAnchor] = useState(null)
|
|
3533
3795
|
|
|
3534
3796
|
useEffect(() => {
|
|
3535
3797
|
let alive = true
|
|
@@ -3560,6 +3822,64 @@ window.__ModuleLoader__.load({
|
|
|
3560
3822
|
}
|
|
3561
3823
|
}, [])
|
|
3562
3824
|
|
|
3825
|
+
// t-89:把「任务看板」文字标签的 rect 换算成角标组坐标。侧栏展开 / 收起(size 16↔18)、
|
|
3826
|
+
// 侧栏宽度拖拽、语言切换、字体加载都会让标签位置变化,所以监听 window resize +
|
|
3827
|
+
// ResizeObserver(图标 / 行 / 标签)+ 2s 兜底轮询;拿不到标签时 setState(null) 退回图标角。
|
|
3828
|
+
// VM 测试没有真实 DOM(ref.current 为 null),effect 直接返回,不排任何定时器。
|
|
3829
|
+
useEffect(() => {
|
|
3830
|
+
const el = iconRef.current
|
|
3831
|
+
if (!el || typeof el.getBoundingClientRect !== 'function') return
|
|
3832
|
+
if (typeof window === 'undefined') return
|
|
3833
|
+
let alive = true
|
|
3834
|
+
let frame = 0
|
|
3835
|
+
const apply = () => {
|
|
3836
|
+
if (!alive) return
|
|
3837
|
+
const next = measureLabelBadgeAnchor(el)
|
|
3838
|
+
setBadgeAnchor((prev) => (sameBadgeAnchor(prev, next) ? prev : next))
|
|
3839
|
+
}
|
|
3840
|
+
const schedule = () => {
|
|
3841
|
+
if (!alive) return
|
|
3842
|
+
if (typeof window.requestAnimationFrame === 'function') {
|
|
3843
|
+
if (frame) return
|
|
3844
|
+
frame = window.requestAnimationFrame(() => {
|
|
3845
|
+
frame = 0
|
|
3846
|
+
apply()
|
|
3847
|
+
})
|
|
3848
|
+
return
|
|
3849
|
+
}
|
|
3850
|
+
apply()
|
|
3851
|
+
}
|
|
3852
|
+
apply()
|
|
3853
|
+
if (typeof window.addEventListener === 'function') window.addEventListener('resize', schedule)
|
|
3854
|
+
let observer = null
|
|
3855
|
+
try {
|
|
3856
|
+
if (typeof window.ResizeObserver === 'function') {
|
|
3857
|
+
observer = new window.ResizeObserver(schedule)
|
|
3858
|
+
observer.observe(el)
|
|
3859
|
+
const row = typeof el.closest === 'function' ? el.closest('button') : null
|
|
3860
|
+
if (row) observer.observe(row)
|
|
3861
|
+
const label = hostLabelNode(row, el)
|
|
3862
|
+
if (label) observer.observe(label)
|
|
3863
|
+
}
|
|
3864
|
+
} catch (e) {
|
|
3865
|
+
observer = null
|
|
3866
|
+
}
|
|
3867
|
+
const stop = every(schedule, 2000)
|
|
3868
|
+
return () => {
|
|
3869
|
+
alive = false
|
|
3870
|
+
stop()
|
|
3871
|
+
if (observer) {
|
|
3872
|
+
try {
|
|
3873
|
+
observer.disconnect()
|
|
3874
|
+
} catch (e) {
|
|
3875
|
+
/* ignore */
|
|
3876
|
+
}
|
|
3877
|
+
}
|
|
3878
|
+
if (typeof window.removeEventListener === 'function') window.removeEventListener('resize', schedule)
|
|
3879
|
+
if (frame && typeof window.cancelAnimationFrame === 'function') window.cancelAnimationFrame(frame)
|
|
3880
|
+
}
|
|
3881
|
+
}, [size])
|
|
3882
|
+
|
|
3563
3883
|
const badge = openCount > 0 ? (openCount > 99 ? '99+' : String(openCount)) : null
|
|
3564
3884
|
const needsBadge = needsCount > 0 ? (needsCount > 99 ? '99+' : String(needsCount)) : null
|
|
3565
3885
|
const tip =
|
|
@@ -3568,12 +3888,24 @@ window.__ModuleLoader__.load({
|
|
|
3568
3888
|
(needsCount > 0 ? ' · ' + t('needsUser.badge', { n: needsCount }) : '')
|
|
3569
3889
|
return h(
|
|
3570
3890
|
'span',
|
|
3571
|
-
{
|
|
3891
|
+
{
|
|
3892
|
+
className: 'tb-icon',
|
|
3893
|
+
title: tip,
|
|
3894
|
+
ref: iconRef,
|
|
3895
|
+
'data-badge-anchor': badgeAnchor ? 'label' : 'icon',
|
|
3896
|
+
style: badgeAnchor
|
|
3897
|
+
? { '--tb-badge-x': badgeAnchor.left + 'px', '--tb-badge-y': badgeAnchor.top + 'px' }
|
|
3898
|
+
: undefined,
|
|
3899
|
+
},
|
|
3572
3900
|
h(BoardGlyph, { size }),
|
|
3573
|
-
badge === null
|
|
3574
|
-
needsBadge === null
|
|
3901
|
+
badge === null && needsBadge === null
|
|
3575
3902
|
? null
|
|
3576
|
-
: h(
|
|
3903
|
+
: h(
|
|
3904
|
+
'span',
|
|
3905
|
+
{ className: 'tb-badges', 'aria-hidden': 'true' },
|
|
3906
|
+
badge === null ? null : h('span', { className: 'tb-badge' }, badge),
|
|
3907
|
+
needsBadge === null ? null : h('span', { className: 'tb-badge tb-badge-needs' }, needsBadge),
|
|
3908
|
+
),
|
|
3577
3909
|
)
|
|
3578
3910
|
}
|
|
3579
3911
|
|
|
@@ -3585,6 +3917,8 @@ window.__ModuleLoader__.load({
|
|
|
3585
3917
|
const [busy, setBusy] = useState('')
|
|
3586
3918
|
const [confirmDeleteId, setConfirmDeleteId] = useState(null)
|
|
3587
3919
|
const [detailId, setDetailId] = useState(null)
|
|
3920
|
+
// t-71:详情浮层内的会话跳转失败提示(渲染在浮层内部;顶部横幅会被 .tb-detail-mask 遮住)。
|
|
3921
|
+
const [detailNotice, setDetailNotice] = useState(null)
|
|
3588
3922
|
// v0.2.2「待你处理」:回答草稿 / 行内错误(详情浮层只读,不持有 state)。
|
|
3589
3923
|
const [answerDraft, setAnswerDraft] = useState('')
|
|
3590
3924
|
const [answerError, setAnswerError] = useState('')
|
|
@@ -3695,6 +4029,9 @@ window.__ModuleLoader__.load({
|
|
|
3695
4029
|
// v0.2.3:新建行的「任务所属工作区」同样按 snapshot.workspaces 校验——
|
|
3696
4030
|
// 选中的工作区在页面打开期间被删 / 改名 → 回退占位(提交重新禁用),不拿失效路径建任务。
|
|
3697
4031
|
const activeWorkspaceCwd = resolveWorkspaceSelection(workspaceCwd, workspaces) || ''
|
|
4032
|
+
// v0.2.4:平台看板卡片上的工作区标签——title 优先、目录名回退、无 cwd 用「—」。
|
|
4033
|
+
// 只传给平台看板的 Col / NeedsColumn;右栏看板本来就绑定单个工作区,不重复显示。
|
|
4034
|
+
const workspaceLabelOf = (task) => taskWorkspaceLabel(workspaces, task)
|
|
3698
4035
|
const visibleAll = tasksForFilter(allTasks, activeFilter)
|
|
3699
4036
|
// v0.2.2(§1.9):flagged 任务只进最左第五列,不重复出现在普通四列。
|
|
3700
4037
|
const needsUser = needsUserTasks(visibleAll)
|
|
@@ -3909,6 +4246,40 @@ window.__ModuleLoader__.load({
|
|
|
3909
4246
|
setNote((prev) => removeAttachmentRef(prev, id))
|
|
3910
4247
|
}
|
|
3911
4248
|
|
|
4249
|
+
/* ── 跳到关联会话(v0.2.4):失败不再静默 ─────────── */
|
|
4250
|
+
/**
|
|
4251
|
+
* 与右栏看板同一套反馈:能打开就跳转,打不开就出 warn 横幅。
|
|
4252
|
+
* t-71:浮层开着时提示渲染在浮层内部(`detailNotice`),否则看板顶部横幅会被遮罩盖住;
|
|
4253
|
+
* 成功跳转只清 `kind:'session'` 的旧提示(不误清派发 / 归档等其它通知)。
|
|
4254
|
+
*/
|
|
4255
|
+
function reportSessionFailure(result, candidates) {
|
|
4256
|
+
if (result && result.ok) {
|
|
4257
|
+
setNotice((prev) => (prev && prev.kind === 'session' ? null : prev))
|
|
4258
|
+
setDetailNotice((prev) => (prev && prev.kind === 'session' ? null : prev))
|
|
4259
|
+
return result
|
|
4260
|
+
}
|
|
4261
|
+
const item = { tone: 'warn', text: sessionFailureText(t, result, candidates), kind: 'session' }
|
|
4262
|
+
if (detailId !== null) {
|
|
4263
|
+
setDetailNotice(item)
|
|
4264
|
+
setNotice((prev) => (prev && prev.kind === 'session' ? null : prev))
|
|
4265
|
+
} else {
|
|
4266
|
+
setNotice(item)
|
|
4267
|
+
}
|
|
4268
|
+
return result
|
|
4269
|
+
}
|
|
4270
|
+
|
|
4271
|
+
/** 单个会话 id 的跳转(组长条 / 详情「关联对话」用)。 */
|
|
4272
|
+
function openSessionAction(sessionId) {
|
|
4273
|
+
return reportSessionFailure(openSessionById(sessionId), [sessionId])
|
|
4274
|
+
}
|
|
4275
|
+
|
|
4276
|
+
/** 任务卡片的「对话」:按候选链(worker → 组长 → 发起 → poll 兜底)试到第一个能打开的。 */
|
|
4277
|
+
function openChatAction(task) {
|
|
4278
|
+
const pieces = boardPiecesRef.current
|
|
4279
|
+
const candidates = pieces && typeof pieces.sessionCandidatesOf === 'function' ? pieces.sessionCandidatesOf(task) : []
|
|
4280
|
+
return reportSessionFailure(openFirstAvailable(candidates), candidates)
|
|
4281
|
+
}
|
|
4282
|
+
|
|
3912
4283
|
/* ── 组长条动作(v0.2.0,与右栏看板同一套 RPC)──────────── */
|
|
3913
4284
|
const leadActions = {
|
|
3914
4285
|
bindMain: () => {
|
|
@@ -3920,7 +4291,7 @@ window.__ModuleLoader__.load({
|
|
|
3920
4291
|
if (typeof cwd !== 'string' || cwd === '') return
|
|
3921
4292
|
run('lead:ensure', () => callRpc('ensure-workspace-lead', { cwd }), t('lead.ensureOk'))
|
|
3922
4293
|
},
|
|
3923
|
-
openSession: (sessionIdToOpen) =>
|
|
4294
|
+
openSession: (sessionIdToOpen) => openSessionAction(sessionIdToOpen),
|
|
3924
4295
|
}
|
|
3925
4296
|
|
|
3926
4297
|
// 组件身份保持稳定(同右栏看板):bind 存 ref、只改字段,pieces 只创建一次。
|
|
@@ -3935,16 +4306,19 @@ window.__ModuleLoader__.load({
|
|
|
3935
4306
|
// v0.2.2:换一条任务就清掉上一条的回答草稿 / 错误,避免答案串台。
|
|
3936
4307
|
setAnswerDraft('')
|
|
3937
4308
|
setAnswerError('')
|
|
4309
|
+
// t-71:上一条任务的会话失败提示也不带到新浮层。
|
|
4310
|
+
setDetailNotice(null)
|
|
3938
4311
|
setDetailId(task.id)
|
|
3939
4312
|
},
|
|
3940
4313
|
// 「对话」按钮传目标会话 id;仍兼容传任务对象的旧调用(取 dispatched → creator)。
|
|
4314
|
+
// 失败(目标会话已关闭 / 服务缺失)出 warn 提示,不再只 console.warn(v0.2.4)。
|
|
3941
4315
|
openSession: (target) => {
|
|
3942
|
-
if (typeof target === 'string')
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
}
|
|
3946
|
-
openSessionById(target && (target.dispatchedSessionId || target.sessionId))
|
|
4316
|
+
if (typeof target === 'string') return openSessionAction(target)
|
|
4317
|
+
const candidates = target ? [target.dispatchedSessionId, target.sessionId] : []
|
|
4318
|
+
return reportSessionFailure(openFirstAvailable(candidates), candidates)
|
|
3947
4319
|
},
|
|
4320
|
+
// 卡片「对话」专用:worker 打不开时回退组长 / 发起会话(候选链见 sessionCandidatesOf)。
|
|
4321
|
+
openChat: (task) => openChatAction(task),
|
|
3948
4322
|
startEdit,
|
|
3949
4323
|
saveEdit,
|
|
3950
4324
|
setEditing,
|
|
@@ -4220,8 +4594,12 @@ window.__ModuleLoader__.load({
|
|
|
4220
4594
|
'div',
|
|
4221
4595
|
{ className: 'tb-board', 'data-layout': 'wide', 'data-needs': needsUser.length > 0 ? 'true' : 'false' },
|
|
4222
4596
|
// 第五列「待你处理」放最左(在「待开始」之前),仅非空时渲染。
|
|
4223
|
-
needsUser.length > 0
|
|
4224
|
-
|
|
4597
|
+
needsUser.length > 0
|
|
4598
|
+
? h(NeedsColumn, { key: 'needsUser', tasks: needsUser, workspaceLabel: workspaceLabelOf })
|
|
4599
|
+
: null,
|
|
4600
|
+
STATUS_ORDER.map((status) =>
|
|
4601
|
+
h(Col, { key: status, status, tasks: groups[status], compact: false, workspaceLabel: workspaceLabelOf }),
|
|
4602
|
+
),
|
|
4225
4603
|
),
|
|
4226
4604
|
|
|
4227
4605
|
h(
|
|
@@ -4238,14 +4616,19 @@ window.__ModuleLoader__.load({
|
|
|
4238
4616
|
task: detailTask,
|
|
4239
4617
|
onClose: () => {
|
|
4240
4618
|
setDetailId(null)
|
|
4619
|
+
setDetailNotice(null)
|
|
4241
4620
|
setAnswerDraft('')
|
|
4242
4621
|
setAnswerError('')
|
|
4243
4622
|
},
|
|
4244
4623
|
onStatus: (status) => {
|
|
4245
4624
|
setDetailId(null)
|
|
4625
|
+
setDetailNotice(null)
|
|
4246
4626
|
updateTask(detailTask.id, { status })
|
|
4247
4627
|
},
|
|
4248
|
-
|
|
4628
|
+
// t-71:浮层内会话按钮失败时,提示条渲染在浮层内部(遮罩盖住顶部的 notice 横幅)。
|
|
4629
|
+
notice: detailNotice,
|
|
4630
|
+
onDismissNotice: () => setDetailNotice(null),
|
|
4631
|
+
openSession: (sessionId) => openSessionAction(sessionId),
|
|
4249
4632
|
})
|
|
4250
4633
|
: null,
|
|
4251
4634
|
)
|
|
@@ -4371,6 +4754,9 @@ window.__ModuleLoader__.load({
|
|
|
4371
4754
|
normalizePath,
|
|
4372
4755
|
samePath,
|
|
4373
4756
|
workspaceTitleOf,
|
|
4757
|
+
// v0.2.4:平台看板卡片的工作区标签(title 优先 / 目录名回退 / 空 cwd 占位)
|
|
4758
|
+
taskWorkspaceLabel,
|
|
4759
|
+
workspaceLabelNone: WORKSPACE_LABEL_NONE,
|
|
4374
4760
|
tasksForWorkspace,
|
|
4375
4761
|
tasksForFilter,
|
|
4376
4762
|
// v0.2.3:看板「工作区」过滤选择的恢复 / 脏值回退
|
|
@@ -4405,6 +4791,9 @@ window.__ModuleLoader__.load({
|
|
|
4405
4791
|
// v0.2.2「待你处理」(§1.9)派生列表
|
|
4406
4792
|
needsUserTasks,
|
|
4407
4793
|
withoutNeedsUser,
|
|
4794
|
+
// t-89:侧栏角标贴「任务看板」文字右上角(标签 rect → 相对图标坐标 / 找宿主标签节点)
|
|
4795
|
+
labelBadgeAnchor,
|
|
4796
|
+
hostLabelNode,
|
|
4408
4797
|
}
|
|
4409
4798
|
|
|
4410
4799
|
return module.exports
|