dsh-progress-union 0.5.5 → 0.5.7

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/CHANGELOG.md CHANGED
@@ -2,6 +2,37 @@
2
2
 
3
3
  本项目的所有值得记录的变更都写在这里。版本号遵循语义化版本。
4
4
 
5
+ ## 0.5.7 (2026-12-01)
6
+
7
+ **fix(头部入口找回) + feat(better-sidebar 独立页签) —— 两条互不合并的工作流。**
8
+
9
+ W1 头部图标(`conversation.session.header.utilities`,右栏开关左侧那排):
10
+
11
+ - **fix(分面隔离)**:apply 里 7 个入口面(设置分节 / 配置卡 / 右栏类型 / 右栏正文 / 整页面板 / 头部图标 / 迷你条)改为各自 `safeEffect` 注册,任一面的同步抛错只 `console.warn` 一行、不再中止整个 apply。此前一处失败会连带头部图标、迷你条、右栏页签一起消失——用户看到的就是「入口没了」。
12
+ - **fix(渲染兜底)**:`ProgressHeaderButton` 拆出内层组件并套 `HeaderEntryBoundary`(`getDerivedStateFromError` → 渲染 null)。组件渲染期抛错只会让这一枚图标不出现,不会拖垮整条 utilities 行。
13
+ - **fix(顺序)**:`order: 12 → 5`,排在宿主自带 utilities 之后、其余插件入口之前;窄窗口从尾部裁切时就裁不到它。
14
+ - 宿主侧核对:`slots`/`locale`/`layout`/`sidebarRight`/`sidebarRightTabs`/`sessions` 六个服务在当前宿主 bundle 里都存在(`app.asar` 字符串统计 9~134 次),硬 inject 不是本次的失败面,因此保留静态 inject(cordis 的等待语义比运行期探测更可靠),只加隔离与兜底。
15
+
16
+ W2 better-sidebar 页签(`ctx.betterSidebar.registerTab`):
17
+
18
+ - **feat(独立页签)**:新增 `BS_TAB_ID = 'dsh-progress-union:board'`,用 `ctx.inject(['betterSidebar'], …)` 延迟注册,描述符字段齐全(`id/title/description/icon/order:120/single/component`)。正文仍是本插件自有的 `ProgressSidePanel`(任务串联 + 进度条),**不用** better-sidebar 的「任务管理」(那是子代理/后台命令编排视图)。
19
+ - **软依赖**:`package.json` 的 `dsh.client.inject` 与 `dependencies` 都没加 `dsh-better-sidebar`;未安装时该块保持 PENDING,静默跳过,W1 与其它面不受影响。不传 `collapse`/`toggleFullscreen`,避免出现点了没反应的全屏/收起按钮。
20
+ - **文案**:zh/en 各加 `bsDesc`(「任务串联的进度板(不是 better-sidebar 的「任务管理」)」/ "Linked-task progress board (not better-sidebar task manager)")。
21
+ - **test**:`test/client.test.mjs` 新增 4 组契约守卫——头部入口仍在且带错误边界、7 面无裸 `ctx.effect`、better-sidebar 描述符字段齐全且正文为自有板子、软依赖不落 `package.json`、`bsDesc` 双字典齐全。
22
+
23
+ ## 0.5.6 (2026-12-01)
24
+
25
+ **fix(迷你条):主色按钮文字改用 on-color 令牌 —— 玻璃/壁纸皮肤下「继续」不再是一块空色块。**
26
+
27
+ 起因:用户截图里 100% 完成态的迷你条,「继续」只剩一块主色实心,看不到文字(看起来像被颜色盖住)。
28
+
29
+ - **根因**:`.pb-dock-goal-resume` 用 `color: var(--dsw-alias-bg-base)` 当**前景色**。该令牌是「页面底色」语义(宿主 `design-platform.css:177`),`@smalltailqwq/dsh-client-ui-skin-maid-atelier` 等玻璃皮肤会把它设成 `transparent` → 文字透明;默认主题下它恰好是白色,所以平时看不出来,切皮肤/切变体才时好时坏。
30
+ - **fix(前景色)**:`.pb-dock-goal-resume`(含 `:hover`)与 `.pb-btn-primary` 统一改 `var(--dsw-alias-label-on-color, #fff)`——宿主给「有色底上的文字」用的语义令牌(`design-platform.css:254/406`)。
31
+ - **fix(设置卡选中态)**:`.dsu-seg > button[data-on="true"]` 底板 `bg-base` → `bg-layer-1`,玻璃皮肤下分段控件选中段不再"消失"。
32
+ - **fix(双目标辨识)**:文案改「板目标已暂停 / 板目标已受阻 / 板目标推进中」,悬停提示标注「进度板目标,独立于宿主的 /goal」。官方 GoalBar(`ui-goal`,order 10)与 `/progress-goal`(order 5)是两套独立状态机、同挂 `conversation.input.dock`,并排出现时必须能分清谁控制谁。
33
+ - **fix(完成态)**:`done === total` 时不再拼接「预计剩 / 已超预估 / 中断」,只留计数与令牌用量。
34
+ - **test**:新增守卫——全文禁止 `color: var(--dsw-alias-bg-base)`、主按钮/继续按钮的「背景=主色 + 前景=on-color」双断言、板目标文案与 `allDone` 断言;`node --test` 107 用例全绿。
35
+
5
36
  ## 0.5.4 (2026-11-29)
6
37
 
7
38
  **feat(浮窗暂停/继续):迷你条加目标控制按钮,暂停真停、继续真跑。**
package/client.js CHANGED
@@ -11,6 +11,8 @@ window.__ModuleLoader__.load({
11
11
  const PANEL_ID = 'progress-union'
12
12
  const RIGHT_TAB_ID = 'dsh-progress-union'
13
13
  const RIGHT_TAB_KIND = 'progress-union'
14
+ // better-sidebar 独立页签的 id(= SidebarTab.type)。与 RIGHT_TAB_KIND 是两个不同的入口面。
15
+ const BS_TAB_ID = 'dsh-progress-union:board'
14
16
  const PROGRESS_EVENT = 'progress-union:changed'
15
17
 
16
18
  /* __STAR_INLINE_BEGIN__ — 手写内联 star 面板(v1→v2→v3 阶梯,_tools/star-row 计划)。
@@ -22,7 +24,7 @@ window.__ModuleLoader__.load({
22
24
  var REPO_URL = "https://github.com/drscrewdriver/dsh-progress-union";
23
25
  var STAR_NS = "progress-union";
24
26
  var STAR_GEN = "v3"; /* ladder:gen */
25
- var STAR_VERSION = "0.5.5"; /* ladder:ver */
27
+ var STAR_VERSION = "0.5.7"; /* ladder:ver */
26
28
  var LANGS = ["zh", "en", "ja", "ko", "fr", "de", "it", "ru", "es", "pt"];
27
29
 
28
30
  // 三代共享:GitHub 单色 mark(octicon 轮廓,fill 随 currentColor)。
@@ -312,6 +314,7 @@ window.__ModuleLoader__.load({
312
314
  const zh = {
313
315
  nav: '进度板',
314
316
  title: '进度板',
317
+ bsDesc: '任务串联的进度板(不是 better-sidebar 的「任务管理」)',
315
318
  subtitle: '你可以直接修改;Agent 只会在下一步读取你改动的那一部分。',
316
319
  live: '实时同步',
317
320
  saving: '保存中…',
@@ -379,11 +382,11 @@ window.__ModuleLoader__.load({
379
382
  dockAllDone: '全部完成',
380
383
  dockPause: '暂停',
381
384
  dockResume: '继续',
382
- dockPauseHint: '暂停这个长程目标:立即停止当前回合,之后不再自动续轮',
383
- dockResumeHint: '继续这个长程目标:重新武装并立刻派发下一轮',
384
- goalPaused: '目标已暂停',
385
- goalBlocked: '目标已受阻',
386
- goalRunning: '目标推进中',
385
+ dockPauseHint: '暂停这个长程目标(进度板目标,独立于宿主的 /goal):立即停止当前回合,之后不再自动续轮',
386
+ dockResumeHint: '继续这个长程目标(进度板目标,独立于宿主的 /goal):重新武装并立刻派发下一轮',
387
+ goalPaused: '板目标已暂停',
388
+ goalBlocked: '板目标已受阻',
389
+ goalRunning: '板目标推进中',
387
390
  llmTitle: '进度辅助 LLM(审查/槽位/轮次)',
388
391
  llmOn: '已启用',
389
392
  llmOff: '未启用:观察者为规则版(零 LLM 费用)。启用后由辅助模型管理任务槽位、产出续轮建议。',
@@ -486,6 +489,7 @@ window.__ModuleLoader__.load({
486
489
  const en = {
487
490
  nav: 'Progress board',
488
491
  title: 'Progress board',
492
+ bsDesc: 'Linked-task progress board (not better-sidebar task manager)',
489
493
  subtitle: 'Edit anything directly; the agent reads only the changed part at its next step.',
490
494
  live: 'Live sync',
491
495
  saving: 'Saving…',
@@ -553,11 +557,11 @@ window.__ModuleLoader__.load({
553
557
  dockAllDone: 'All done',
554
558
  dockPause: 'Pause',
555
559
  dockResume: 'Resume',
556
- dockPauseHint: 'Pause this long goal: stop the live turn now and stop auto-continuing',
557
- dockResumeHint: 'Resume this long goal: re-arm and dispatch the next round immediately',
558
- goalPaused: 'Goal paused',
559
- goalBlocked: 'Goal blocked',
560
- goalRunning: 'Goal running',
560
+ dockPauseHint: 'Pause this long goal (board goal — separate from the host /goal): stop the live turn now and stop auto-continuing',
561
+ dockResumeHint: 'Resume this long goal (board goal — separate from the host /goal): re-arm and dispatch the next round immediately',
562
+ goalPaused: 'Board goal paused',
563
+ goalBlocked: 'Board goal blocked',
564
+ goalRunning: 'Board goal running',
561
565
  llmTitle: 'Progress assistant LLM (audit/slots/rounds)',
562
566
  llmOn: 'Enabled',
563
567
  llmOff: 'Disabled: the observer is rule-based (zero LLM cost). When enabled, the assistant manages task slots and produces round suggestions.',
@@ -708,7 +712,9 @@ window.__ModuleLoader__.load({
708
712
  }
709
713
  .pb-btn:hover:not(:disabled) { border-color: var(--dsw-alias-border-l2); }
710
714
  .pb-btn:disabled { opacity: .42; cursor: not-allowed; }
711
- .pb-btn-primary { background: var(--dsw-alias-brand-primary); border-color: var(--dsw-alias-brand-primary); color: var(--dsw-alias-bg-base); font-weight: 600; }
715
+ /* 主色实心按钮的文字必须用宿主 on-color 令牌:--dsw-alias-bg-base 是「页面底色」语义,
716
+ 玻璃/壁纸皮肤会把它设成 transparent,当前景色用就等于透明字(maid-atelier 实测)。 */
717
+ .pb-btn-primary { background: var(--dsw-alias-brand-primary); border-color: var(--dsw-alias-brand-primary); color: var(--dsw-alias-label-on-color, #fff); font-weight: 600; }
712
718
  .pb-btn-danger { color: var(--dsw-alias-state-error-primary); }
713
719
  .pb-icon-btn { min-width: 28px; padding: 4px 7px; }
714
720
  .pb-overview {
@@ -862,8 +868,8 @@ window.__ModuleLoader__.load({
862
868
  /* 目标暂停/继续:唯一强调色落在这里,其余动作保持中性灰。 */
863
869
  .pb-dock-goal { font-weight: 600; }
864
870
  .pb-dock-goal-pause { border-color: var(--dsw-alias-brand-primary); color: var(--dsw-alias-brand-primary); }
865
- .pb-dock-goal-resume { border-color: var(--dsw-alias-brand-primary); background: var(--dsw-alias-brand-primary); color: var(--dsw-alias-bg-base); }
866
- .pb-dock-goal-resume:hover { color: var(--dsw-alias-bg-base); filter: brightness(1.06); }
871
+ .pb-dock-goal-resume { border-color: var(--dsw-alias-brand-primary); background: var(--dsw-alias-brand-primary); color: var(--dsw-alias-label-on-color, #fff); }
872
+ .pb-dock-goal-resume:hover { color: var(--dsw-alias-label-on-color, #fff); filter: brightness(1.06); }
867
873
  .pb-dock-expanded {
868
874
  display: flex; flex-direction: column; gap: 3px; margin-top: 7px; padding-top: 7px;
869
875
  border-top: 1px solid var(--dsw-alias-border-l1); max-height: 180px; overflow: auto;
@@ -1069,7 +1075,7 @@ window.__ModuleLoader__.load({
1069
1075
  font: 'inherit',
1070
1076
  }
1071
1077
 
1072
- function ProgressHeaderButton(props) {
1078
+ function ProgressHeaderButtonInner(props) {
1073
1079
  const t = makeT(props)
1074
1080
  // 内联样式优先级高于样式表,hover 变色只能自己管:样式表没到场也要有反馈。
1075
1081
  const [hovered, setHovered] = useState(false)
@@ -1102,6 +1108,34 @@ window.__ModuleLoader__.load({
1102
1108
  )
1103
1109
  }
1104
1110
 
1111
+ /*
1112
+ * 渲染期兜底:宿主的 utilities 是一行内联渲染的列表,本组件若在渲染中抛错
1113
+ * 会连带整排图标一起消失。错误边界把异常挡在入口内部(失败就渲染空),
1114
+ * 最坏表现是「这一枚不出现」,而不是「一排都不出现」。
1115
+ */
1116
+ class HeaderEntryBoundary extends React.Component {
1117
+ constructor(props) {
1118
+ super(props)
1119
+ this.state = { failed: false }
1120
+ }
1121
+
1122
+ static getDerivedStateFromError() {
1123
+ return { failed: true }
1124
+ }
1125
+
1126
+ componentDidCatch(error) {
1127
+ console.warn('[progress-union] header entry render failed', error)
1128
+ }
1129
+
1130
+ render() {
1131
+ return this.state.failed ? null : this.props.children
1132
+ }
1133
+ }
1134
+
1135
+ function ProgressHeaderButton(props) {
1136
+ return h(HeaderEntryBoundary, null, h(ProgressHeaderButtonInner, props))
1137
+ }
1138
+
1105
1139
  function EditableText({ value, placeholder, onCommit, multiline, className, disabled, ariaLabel }) {
1106
1140
  const [draft, setDraft] = useState(value || '')
1107
1141
  const [focused, setFocused] = useState(false)
@@ -1570,9 +1604,11 @@ window.__ModuleLoader__.load({
1570
1604
 
1571
1605
  const sub = [`${summary.done}/${summary.total} ${t('doneCount')}`]
1572
1606
  if (summary.blocked) sub.push(`${summary.blocked} ${t('blockedCount')}`)
1573
- if (timing && timing.overMin > 0) sub.push(`${t('etaOver')} ${timing.overMin} min`)
1574
- else if (timing && timing.staleMin > 0) sub.push(`${t('staleTag')} ${timing.staleMin} min`)
1575
- else if (timing && timing.etaMin > 0) sub.push(`${t('etaLeft')} ${timing.etaMin} min`)
1607
+ // 全部完成时时间面(预计剩/已超预估/中断)没有意义——完成态只留计数与令牌用量。
1608
+ const allDone = summary.total > 0 && summary.done === summary.total
1609
+ if (!allDone && timing && timing.overMin > 0) sub.push(`${t('etaOver')} ${timing.overMin} min`)
1610
+ else if (!allDone && timing && timing.staleMin > 0) sub.push(`${t('staleTag')} ${timing.staleMin} min`)
1611
+ else if (!allDone && timing && timing.etaMin > 0) sub.push(`${t('etaLeft')} ${timing.etaMin} min`)
1576
1612
  if (snapshot.pendingUserChanges) sub.push(`${snapshot.pendingUserChanges} ${t('dockPending')}`)
1577
1613
  if (snapshot.enabled === false) sub.push(t('autoOff'))
1578
1614
  const goalPhase = snapshot.goal && snapshot.goal.phase ? String(snapshot.goal.phase) : ''
@@ -1960,7 +1996,8 @@ window.__ModuleLoader__.load({
1960
1996
  .dsu-switch input:checked + i::after { transform: translateX(17px); }
1961
1997
  .dsu-seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: 9px; background: rgba(128,128,128,.14); }
1962
1998
  .dsu-seg > button { appearance: none; border: 0; background: transparent; color: inherit; font: inherit; font-size: 12px; padding: 5px 12px; border-radius: 7px; cursor: pointer; opacity: .72; white-space: nowrap; }
1963
- .dsu-seg > button[data-on="true"] { background: var(--dsw-alias-bg-base, #fff); box-shadow: 0 1px 3px rgba(0,0,0,.14); opacity: 1; font-weight: 600; }
1999
+ /* 选中态底板不能用 bg-base:玻璃皮肤把它设成 transparent,选中段就"消失"了。 */
2000
+ .dsu-seg > button[data-on="true"] { background: var(--dsw-alias-bg-layer-1, #fff); box-shadow: 0 1px 3px rgba(0,0,0,.14); opacity: 1; font-weight: 600; }
1964
2001
  .dsu-actions { display: flex; align-items: center; gap: 10px; padding-top: 2px; }
1965
2002
  .dsu-actions .dsu-spacer { flex: 1; }
1966
2003
  .dsu-btn { appearance: none; font: inherit; font-size: 12px; padding: 6px 14px; border-radius: 8px; cursor: pointer; border: 1px solid var(--dsw-alias-border-l1, rgba(128,128,128,.3)); background: transparent; color: inherit; }
@@ -3024,6 +3061,22 @@ window.__ModuleLoader__.load({
3024
3061
 
3025
3062
  const t = ctx.locale.bind(NS)
3026
3063
 
3064
+ /*
3065
+ * 分面隔离:一个入口注册失败不得拖垮其余面。
3066
+ * 之前各面直接串在 apply 里,任何一处同步抛错都会中止 apply ——
3067
+ * 用户看到的是「头部图标、迷你条、右栏页签一起没了」,现场只剩一条报错。
3068
+ * 现在每面各自 try/catch 并留一行 console.warn,能直接看出坏的是哪一面。
3069
+ */
3070
+ const safeEffect = (label, register) =>
3071
+ ctx.effect(() => {
3072
+ try {
3073
+ return register()
3074
+ } catch (error) {
3075
+ console.warn('[progress-union] ' + label + ' 注册失败', error)
3076
+ return () => {}
3077
+ }
3078
+ }, 'progress-union: ' + label)
3079
+
3027
3080
  // 双座位注册:顶层设置分节(settings.section)+ 插件详情页配置卡
3028
3081
  // (plugins.bundle.config,keyed by **包名**)。
3029
3082
  // configForms 可能在 apply 之后才就绪 → 走 deferred inject 捕获句柄,
@@ -3045,13 +3098,13 @@ window.__ModuleLoader__.load({
3045
3098
  ProgressUnionSettings,
3046
3099
  ),
3047
3100
  )
3048
- ctx.effect(
3101
+ safeEffect(
3102
+ 'settings section',
3049
3103
  () => registerSettingsSeat('settings.section', { id: 'dsh-progress-union', order: 215, label: () => t('setTitle') }),
3050
- 'progress-union: settings section',
3051
3104
  )
3052
- ctx.effect(
3105
+ safeEffect(
3106
+ 'bundle config card',
3053
3107
  () => registerSettingsSeat('plugins.bundle.config', { key: 'dsh-progress-union', order: 15 }),
3054
- 'progress-union: bundle config card',
3055
3108
  )
3056
3109
 
3057
3110
  const wakeAgent = (sessionId, text) => {
@@ -3125,7 +3178,8 @@ window.__ModuleLoader__.load({
3125
3178
  if (target) ctx.sidebarRight.toggleFullscreen(target)
3126
3179
  }
3127
3180
 
3128
- ctx.effect(
3181
+ safeEffect(
3182
+ 'right sidebar type',
3129
3183
  () =>
3130
3184
  ctx.sidebarRightTabs.register({
3131
3185
  id: RIGHT_TAB_ID,
@@ -3133,10 +3187,10 @@ window.__ModuleLoader__.load({
3133
3187
  priority: 'extension',
3134
3188
  title: () => t('nav'),
3135
3189
  }),
3136
- 'progress-union: right sidebar type',
3137
3190
  )
3138
3191
 
3139
- ctx.effect(
3192
+ safeEffect(
3193
+ 'right sidebar body',
3140
3194
  () =>
3141
3195
  ctx.slots.inject('sidebar.right.pane.tab', () =>
3142
3196
  ctx.slots.register(
@@ -3155,10 +3209,10 @@ window.__ModuleLoader__.load({
3155
3209
  ProgressSidePanel,
3156
3210
  ),
3157
3211
  ),
3158
- 'progress-union: right sidebar body',
3159
3212
  )
3160
3213
 
3161
- ctx.effect(
3214
+ safeEffect(
3215
+ 'full panel',
3162
3216
  () =>
3163
3217
  ctx.slots.inject('main', () =>
3164
3218
  ctx.slots.register(
@@ -3171,27 +3225,29 @@ window.__ModuleLoader__.load({
3171
3225
  ProgressPanel,
3172
3226
  ),
3173
3227
  ),
3174
- 'progress-union: full panel',
3175
3228
  )
3176
3229
 
3177
- ctx.effect(
3230
+ safeEffect(
3231
+ 'header button',
3178
3232
  () =>
3179
3233
  ctx.slots.inject('conversation.session.header.utilities', () =>
3180
3234
  ctx.slots.register(
3181
3235
  {
3182
3236
  name: 'conversation.session.header.utilities',
3183
3237
  id: 'progress-union-header',
3184
- order: 12,
3238
+ // 5:比其它插件入口靠前(宿主自带入口更小)。窄窗口压缩 utilities 行时
3239
+ // 裁切方向未实测,靠前是安全侧——最坏也只是排在别人前面,不会先被挤掉。
3240
+ order: 5,
3185
3241
  locale: NS,
3186
3242
  inject: () => ({ openPanel: togglePanel }),
3187
3243
  },
3188
3244
  ProgressHeaderButton,
3189
3245
  ),
3190
3246
  ),
3191
- 'progress-union: header button',
3192
3247
  )
3193
3248
 
3194
- ctx.effect(
3249
+ safeEffect(
3250
+ 'composer dock',
3195
3251
  () =>
3196
3252
  ctx.slots.inject('conversation.input.dock', () =>
3197
3253
  ctx.slots.register(
@@ -3205,8 +3261,48 @@ window.__ModuleLoader__.load({
3205
3261
  ProgressDock,
3206
3262
  ),
3207
3263
  ),
3208
- 'progress-union: composer dock',
3209
3264
  )
3265
+
3266
+ /*
3267
+ * W2:better-sidebar 上的独立页签(与 W1 的原生右栏页签互不替代)。
3268
+ *
3269
+ * 内容仍是本插件自有的 ProgressSidePanel(任务串联 + 进度条),不复用
3270
+ * better-sidebar 的「任务管理」—— 那是子代理/后台命令的编排视图,与本板的
3271
+ * 任务串联设计不是一回事。
3272
+ *
3273
+ * 软依赖:用 deferred inject 等它出现,package.json 的 dsh.client.inject 与
3274
+ * dependencies 都不写它;未安装时此块保持 PENDING → 静默跳过,不影响 W1。
3275
+ */
3276
+ try {
3277
+ ctx.inject(['betterSidebar'], (bs) => {
3278
+ const service = bs.betterSidebar
3279
+ if (!service || typeof service.registerTab !== 'function') return
3280
+ bs.effect(
3281
+ () =>
3282
+ service.registerTab({
3283
+ id: BS_TAB_ID,
3284
+ title: () => t('nav'),
3285
+ description: () => t('bsDesc'),
3286
+ icon: (size) => h(ProgressNavIcon, { size: size || 16 }),
3287
+ order: 120,
3288
+ single: true,
3289
+ // collapse / toggleFullscreen 故意不传:ProgressSidePanel 里都是 ?. 调用,
3290
+ // 传了反而会在 better-sidebar 里出现点了没反应的全屏/收起按钮。
3291
+ component: (tabProps) =>
3292
+ h(ProgressSidePanel, {
3293
+ sessionId: tabProps && tabProps.scope ? tabProps.scope.sessionId : undefined,
3294
+ t,
3295
+ usage: usageApi,
3296
+ wakeAgent,
3297
+ openFullPanel,
3298
+ }),
3299
+ }),
3300
+ 'progress-union: better-sidebar tab',
3301
+ )
3302
+ })
3303
+ } catch (error) {
3304
+ console.warn('[progress-union] better-sidebar tab 注册失败', error)
3305
+ }
3210
3306
  },
3211
3307
  }
3212
3308
  },
package/dsh.plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "id": "dsh-external/dsh-progress-union",
3
- "version": "0.5.5",
3
+ "version": "0.5.7",
4
4
  "main": "./index.js",
5
5
  "description": "进度结合原型:board 槽位真相源(用户可编辑、diff+ack 增量同步、staleness nudge)× 鲸程时间引擎(step 计数、ETA 三档 board>todo>local>prior、悬浮迷你条),并向压缩插件暴露只读三层进度锚点 progressAnchor(board 语义锚 + time 时间锚 + userEdits 未确认改动,service 与 HTTP 双平面)。",
6
6
  "engines": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-progress-union",
3
- "version": "0.5.5",
3
+ "version": "0.5.7",
4
4
  "type": "module",
5
5
  "description": "进度结合原型:dsh-progress-board 槽位真相源 × 鲸程 widget 时间/ETA 引擎,另向压缩插件暴露只读三层进度锚点(service + HTTP 双平面)。基于 l3j3y3/dsh-progress-board (MIT) 与 uuhihj/task-progress-bar dsh-progress-widget (MIT)。",
6
6
  "license": "MIT",
@@ -17,6 +17,7 @@ const { SESSION, createHarness, jsonReq, callRoute } = await import('./harness.m
17
17
  // 必须用 fileURLToPath:`new URL(...).pathname` 在 Windows 得到 `/E:/...`(需去前导斜杠),
18
18
  // 但 Linux 的 `/` 是根目录,`.replace(/^[/]/,'')` 会把它变成相对路径 → CI 上 ENOENT。
19
19
  const clientFile = fileURLToPath(new URL('../client.js', import.meta.url))
20
+ const packageFile = fileURLToPath(new URL('../package.json', import.meta.url))
20
21
 
21
22
  test('client.js 命名空间已切到 union,无 progress-board API 残留', () => {
22
23
  const src = fs.readFileSync(clientFile, 'utf8')
@@ -39,8 +40,85 @@ test('迷你条暂停/继续按钮接线齐全(渲染 + 请求 + 状态门控
39
40
  // 门控:只有目标 active 才给暂停,只有 paused/blocked 才给继续
40
41
  assert.match(src, /goalActive = goalPhase === 'active'/, '暂停按钮必须按 phase 门控')
41
42
  assert.match(src, /goalStopped = goalPhase === 'paused' \|\| goalPhase === 'blocked'/, '继续按钮必须按 phase 门控')
42
- // 按钮样式必须真的存在(否则是裸浏览器按钮)
43
+ // 按钮样式必须真的存在(否则是裸浏览器按钮):背景=主色实心,前景=宿主 on-color 令牌。
43
44
  assert.match(src, /\.pb-dock-goal-resume \{[^}]*background: var\(--dsw-alias-brand-primary\)/, '继续按钮需要有主色实心样式')
45
+ assert.match(src, /\.pb-dock-goal-resume \{[^}]*color: var\(--dsw-alias-label-on-color/, '继续按钮前景必须用 on-color 令牌')
46
+ })
47
+
48
+ test('主色实心按钮的前景色不得用 bg-base(玻璃皮肤会把它设成 transparent)', () => {
49
+ const src = fs.readFileSync(clientFile, 'utf8')
50
+ // 事故:maid-atelier 皮肤在 body 上把 --dsw-alias-bg-base 设为 transparent,
51
+ // 拿它当 color 会让「继续」渲染成透明字 → 看着像一块纯色块盖住了按钮。
52
+ assert.doesNotMatch(src, /color:\s*var\(--dsw-alias-bg-base/, '--dsw-alias-bg-base 是页面底色语义,不能当前景色')
53
+ assert.match(src, /\.pb-btn-primary \{[^}]*color: var\(--dsw-alias-label-on-color/, '主按钮前景必须用 on-color 令牌')
54
+ // 选择态底板同样不能用 bg-base(透明后选中段会"消失")。
55
+ assert.doesNotMatch(src, /\[data-on="true"\] \{[^}]*background: var\(--dsw-alias-bg-base/, '分段控件选中态不得用 bg-base 做底板')
56
+ })
57
+
58
+ test('目标文案区分「板目标」与宿主 goal,完成态不报时间面', () => {
59
+ const src = fs.readFileSync(clientFile, 'utf8')
60
+ // 官方 GoalBar 与 /progress-goal 是两套状态机,并排在同一 input dock:文案必须能分辨。
61
+ assert.match(src, /goalPaused: '板目标已暂停'/, 'zh 文案需带「板目标」前缀')
62
+ assert.match(src, /goalPaused: 'Board goal paused'/, 'en 文案需带 Board goal 前缀')
63
+ assert.match(src, /独立于宿主的 \/goal/, '悬停提示需说明与宿主 /goal 的关系')
64
+ assert.match(src, /const allDone = summary\.total > 0 && summary\.done === summary\.total/, '完成态需跳过时间面')
65
+ })
66
+
67
+ test('W1: 头部入口注册仍在,且带渲染兜底与分面隔离', () => {
68
+ // 仓内文件是 CRLF:多行断言前先归一,否则 \n 永远匹配不到 \r\n。
69
+ const src = fs.readFileSync(clientFile, 'utf8').replace(/\r\n/g, '\n')
70
+ // 入口本体:槽位 + id + 顺序(5 = 排在宿主自带入口之后、其余插件之前,窄窗口不会被裁掉)
71
+ assert.match(src, /name: 'conversation\.session\.header\.utilities'/, '头部工具区槽位注册必须在')
72
+ assert.match(src, /id: 'progress-union-header'/, '头部入口 id 必须在')
73
+ assert.match(src, /order: 5,/, '头部入口顺序必须提前到 5')
74
+ // 渲染兜底:组件抛错只让这一枚消失,不拖垮整排 utilities
75
+ assert.match(src, /class HeaderEntryBoundary extends React\.Component/, '头部入口必须有错误边界')
76
+ assert.match(src, /getDerivedStateFromError/, '错误边界必须真的降级渲染')
77
+ assert.match(src, /function ProgressHeaderButton\(props\) \{\n return h\(HeaderEntryBoundary/, '导出组件必须包在错误边界里')
78
+ // 分面隔离:任一入口注册失败不得中止 apply(否则图标/迷你条/右栏页签一起消失)
79
+ assert.match(src, /const safeEffect = \(label, register\) =>/, '必须有分面隔离助手')
80
+ const safeCalls = src.match(/^\s+safeEffect\($/gm) || []
81
+ assert.equal(safeCalls.length, 7, '七个入口面都必须经 safeEffect 注册')
82
+ const bare = src.match(/ctx\.effect\(\s*\n\s*\(\) =>\s*\n\s*ctx\.(slots|sidebarRightTabs)/g) || []
83
+ assert.equal(bare.length, 0, '不得残留裸 ctx.effect 入口注册')
84
+ })
85
+
86
+ test('W2: better-sidebar 页签是独立入口,内容仍是自有板子', () => {
87
+ const src = fs.readFileSync(clientFile, 'utf8').replace(/\r\n/g, '\n')
88
+ assert.match(src, /const BS_TAB_ID = 'dsh-progress-union:board'/, 'better-sidebar 页签 id 必须在')
89
+ assert.doesNotMatch(src, /const BS_TAB_ID = 'progress-union'|const BS_TAB_ID = 'dsh-progress-union'\n/, '页签 id 不得与原生 kind 混用')
90
+ // 服务可能晚于 apply 就绪 → 必须 deferred inject,不能一次性 ctx.get
91
+ assert.match(src, /ctx\.inject\(\['betterSidebar'\], \(bs\) => \{/, '必须用 deferred inject 等待 betterSidebar')
92
+ assert.match(src, /typeof service\.registerTab !== 'function'/, '调用前必须探测 registerTab')
93
+ // 描述符字段齐全
94
+ assert.match(src, /id: BS_TAB_ID,/)
95
+ assert.match(src, /title: \(\) => t\('nav'\),/)
96
+ assert.match(src, /description: \(\) => t\('bsDesc'\),/)
97
+ assert.match(src, /icon: \(size\) => h\(ProgressNavIcon, \{ size: size \|\| 16 \}\)/)
98
+ assert.match(src, /order: 120,/)
99
+ assert.match(src, /single: true,/)
100
+ // 内容是自有板子,且拿到当前会话
101
+ assert.match(src, /h\(ProgressSidePanel, \{/, '页签正文必须是自有 ProgressSidePanel')
102
+ assert.match(src, /sessionId: tabProps && tabProps\.scope \? tabProps\.scope\.sessionId : undefined/)
103
+ // 不传 collapse / toggleFullscreen,避免 better-sidebar 里出现死按钮
104
+ const block = src.slice(src.indexOf("ctx.inject(['betterSidebar']"), src.indexOf("'progress-union: better-sidebar tab'"))
105
+ assert.doesNotMatch(block, /collapse:/, '不得向 better-sidebar 页签传 collapse')
106
+ assert.doesNotMatch(block, /toggleFullscreen:/, '不得向 better-sidebar 页签传 toggleFullscreen')
107
+ // 明确不复用 better-sidebar 的「任务管理」
108
+ assert.doesNotMatch(block, /task.?manage|subagent|后台命令/iu, '不得复用 better-sidebar 的任务管理视图')
109
+ })
110
+
111
+ test('W2: better-sidebar 只是软依赖(未装者必须照常加载)', () => {
112
+ const pkg = JSON.parse(fs.readFileSync(packageFile, 'utf8'))
113
+ const declared = pkg.dsh?.client?.inject ?? []
114
+ assert.equal(declared.includes('dsh-better-sidebar'), false, 'dsh.client.inject 不得声明 dsh-better-sidebar')
115
+ assert.equal('dsh-better-sidebar' in (pkg.dependencies ?? {}), false, 'dependencies 不得声明 dsh-better-sidebar')
116
+ })
117
+
118
+ test('S2: bsDesc 在 zh/en 两个字典里都存在', () => {
119
+ const src = fs.readFileSync(clientFile, 'utf8').replace(/\r\n/g, '\n')
120
+ assert.match(src, /bsDesc: '任务串联的进度板(不是 better-sidebar 的「任务管理」)'/, 'zh 文案必须在')
121
+ assert.match(src, /bsDesc: 'Linked-task progress board \(not better-sidebar task manager\)'/, 'en 文案必须在')
44
122
  })
45
123
 
46
124
  test('宿主 snapshot/status 两路由的客户端消费形状', async () => {