dsh-dispatch-board 0.2.4 → 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/lib/client.js +159 -4
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -154,6 +154,23 @@ window.__ModuleLoader__.load({
|
|
|
154
154
|
'.tb-headbtn:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}',
|
|
155
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}',
|
|
156
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}',
|
|
157
174
|
'.tb-tabtitle{display:inline-flex;align-items:center;gap:5px;min-width:0}',
|
|
158
175
|
// 右栏 tab 的关闭按钮由宿主 dockkit chrome 渲染(本插件只提供正文与 chip):宿主 CSS 会在
|
|
159
176
|
// tab active / focus-within 时强制显示关闭按钮。这里只收紧带本插件标题(.tb-tabtitle)的 tab——
|
|
@@ -1690,6 +1707,68 @@ window.__ModuleLoader__.load({
|
|
|
1690
1707
|
return text === known ? error.message || t('error.internal') : text
|
|
1691
1708
|
}
|
|
1692
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
|
+
|
|
1693
1772
|
/* ══════════════════════════════════════════════════════════════
|
|
1694
1773
|
* 插件主体
|
|
1695
1774
|
* ══════════════════════════════════════════════════════════════ */
|
|
@@ -3710,6 +3789,9 @@ window.__ModuleLoader__.load({
|
|
|
3710
3789
|
const [openCount, setOpenCount] = useState(-1)
|
|
3711
3790
|
// v0.2.2(§1.9):待你处理数量单独一个红色角标。
|
|
3712
3791
|
const [needsCount, setNeedsCount] = useState(-1)
|
|
3792
|
+
const iconRef = useRef(null)
|
|
3793
|
+
// t-89:角标组相对 .tb-icon 的偏移(null = 还没量到宿主标签 → CSS 退回图标右上角)。
|
|
3794
|
+
const [badgeAnchor, setBadgeAnchor] = useState(null)
|
|
3713
3795
|
|
|
3714
3796
|
useEffect(() => {
|
|
3715
3797
|
let alive = true
|
|
@@ -3740,6 +3822,64 @@ window.__ModuleLoader__.load({
|
|
|
3740
3822
|
}
|
|
3741
3823
|
}, [])
|
|
3742
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
|
+
|
|
3743
3883
|
const badge = openCount > 0 ? (openCount > 99 ? '99+' : String(openCount)) : null
|
|
3744
3884
|
const needsBadge = needsCount > 0 ? (needsCount > 99 ? '99+' : String(needsCount)) : null
|
|
3745
3885
|
const tip =
|
|
@@ -3748,12 +3888,24 @@ window.__ModuleLoader__.load({
|
|
|
3748
3888
|
(needsCount > 0 ? ' · ' + t('needsUser.badge', { n: needsCount }) : '')
|
|
3749
3889
|
return h(
|
|
3750
3890
|
'span',
|
|
3751
|
-
{
|
|
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
|
+
},
|
|
3752
3900
|
h(BoardGlyph, { size }),
|
|
3753
|
-
badge === null
|
|
3754
|
-
needsBadge === null
|
|
3901
|
+
badge === null && needsBadge === null
|
|
3755
3902
|
? null
|
|
3756
|
-
: 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
|
+
),
|
|
3757
3909
|
)
|
|
3758
3910
|
}
|
|
3759
3911
|
|
|
@@ -4639,6 +4791,9 @@ window.__ModuleLoader__.load({
|
|
|
4639
4791
|
// v0.2.2「待你处理」(§1.9)派生列表
|
|
4640
4792
|
needsUserTasks,
|
|
4641
4793
|
withoutNeedsUser,
|
|
4794
|
+
// t-89:侧栏角标贴「任务看板」文字右上角(标签 rect → 相对图标坐标 / 找宿主标签节点)
|
|
4795
|
+
labelBadgeAnchor,
|
|
4796
|
+
hostLabelNode,
|
|
4642
4797
|
}
|
|
4643
4798
|
|
|
4644
4799
|
return module.exports
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-dispatch-board",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "DeepSeek Harness 插件:派单看板 + 派单模式。主 Agent 只拆解/派发/审核/汇报,子 Agent 干活;看板四列(待开始/进行中/已完成/已归档)由轮询自动派发,结论按 Markdown 展示。Dispatcher mode plus a dispatch board for DeepSeek Harness.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|