dsh-todo-board 0.11.2 → 0.11.4

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
@@ -1,5 +1,61 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.11.4
4
+
5
+ **修复:筛选页签永远是空的,而且从面板新建的待办不带目录、不带来源会话。**
6
+
7
+ - **根因是一次读了一个不存在的字段。** 面板用
8
+ `props.useSessions((s) => s.current)` 取当前会话,而会话列表 store 的快照是
9
+ `{ ids, byId, phase, projectionsBySession }` —— **它没有 `current` 键**,这个读法**恒为 `undefined`**。
10
+ 于是 `currentId` 是 `undefined`、`cwd` 是 `''`,两个页签的判据分别变成
11
+ 「`sourceSessionId === undefined`」和「`dir === ''`」,**没有任何一行能匹配**。
12
+ - **症状为什么会长成那个样子**:行上的目录标签来自宿主 payload(`dirLabel`,服务端现算),
13
+ 一直是**对的**;只有两个筛选键塌了。所以看起来像"筛选坏了",而不是"读了一个不存在的字段"——
14
+ 这也正是它藏了这么久的原因。
15
+ - 现在按 **harness 自己的判据**推导当前会话:`retainedBy.mainView > 0` 的那一行
16
+ (`dsh-client-ui-layout` / `-workspace` / `-cordis` / `-settings-general` / `-session` 都是这个写法),
17
+ 所以语义跟着平台走,不是我们另发明一个。
18
+ - **同一个死读还有第二重后果,而且会被持久化**:新建待办时送出的是
19
+ `dir: cwd`(空)、`sessionId: currentId`(空)、`sessionTitle: currentTitle`(空)。
20
+ 也就是说在修复之前、从面板建的待办**落库时就没有目录、没有来源会话**——那条行之后
21
+ 既不会出现在「当前目录」里,也不会显示会话标签,更没有可接续的会话。
22
+ **代码修好也救不回已经写下的行**:这种行需要手动改一次目录(或删掉重建)。
23
+ (已核对本机 board:7 条待办都来自模型工具、目录与会话都正常,没有受影响的存量数据。)
24
+ - **测试:夹具喂的是一个假形状,所以这个 bug 一直是绿的。**
25
+ - `client-smoke.mjs` 的 `useSessions` 桩原来写的是 `{ current: 's1', byId: … }` ——
26
+ 真实 store 从不发 `current`。**桩回答了一个线上永远不会被问的问题**,于是线上坏、测试绿。
27
+ 一个凭空发明字段的夹具比没有夹具更糟:它把一个活 bug 变成了一条通过的测试。
28
+ - 夹具现在用真实形状,并**故意把当前会话放在 `byId` 的第二位**:只喂一个会话时,
29
+ "取第一行"和"找被 mainView 保留的那行"是同一件事,测试会为一个它从没检查过的原因通过。
30
+ - 新增 `scope` 段:三个页签**按行**断言(高亮着却列出空,正是要抓的失败态),
31
+ 并断言计数与切换后的收窄结果。
32
+ - `pastelimit` 段补了新建待办的三条断言(`dir` / `sessionId` / `sessionTitle`)——
33
+ 钉住那个会被持久化的边界,因为写坏的存量数据没法靠改代码恢复。
34
+ - `check-row-guard` 新增 4 条变异体(共 **35** 条):退回 `s.current`、
35
+ 忽略 `retainedBy` 判据、两个页签各自不再收窄。全部被抓。
36
+ - 文档:更正 README 的版本边界 —— 逐版本核对 npm 上的实物后确认
37
+ **0.11.2 才是第一个带 v4 适配的发布版**(此前误写成 0.11.3);
38
+ 不带宽适配的发布版只有 `0.4.1 / 0.5.0 / 0.6.1`。
39
+
40
+ ## 0.11.3
41
+
42
+ 发布后核对 npm 上的实物才发现的两件事,都修在这里。
43
+
44
+ - **修复:npm 包页面上的 README 图片全是坏的。**
45
+ - `package.json` 的 `files` 白名单里没有 `assets/`。README 用的是相对路径(`assets/screenshot-2.png`),
46
+ 在 GitHub 上从仓库根解析得到,但 **npm 的包页面用的是 tarball 里的 README**,而 tarball 里根本没有那几张图。
47
+ - 后果很隐蔽:**仓库里一切正常,只有 npm 页面上是四个破图** —— 而 npm 页面恰恰是别人评估这个包的地方。
48
+ - 现在 `files` 里加上 `assets`,四张图(约 3 MB)随包发布。已用「从 registry 下载 tarball 逐个核对」
49
+ 的方式验证,不再靠肉眼。
50
+ - **更正:`engines.dsh` 不会在安装时给任何警告 —— 之前 README 与 CHANGELOG 写错了。**
51
+ - 0.11.2 的文档说"装错版本时 npm 会在安装时给出警告"。**实测不成立**:在 DSH 0.1.5 / 0.1.6 下
52
+ 安装本插件(`npm install` 真跑,`--dry-run` 与实装都试过)**没有** `EBADENGINE`。
53
+ - 原因:npm 只校验它认识的引擎名(`node` / `npm`),`dsh` 这个自定义名字不在其列 ——
54
+ 这个字段因此只是**声明**,不构成任何保护。把它当护栏写进文档,是把"我声明了"讲成了"它会拦"。
55
+ - README 现在如实写:装错版本**没有安装期告警**,实际表现是**整个回合在运行时失败**,原因进插件日志。
56
+ - 顺带记一笔方法论:这条错误只有**真去装一次**才会暴露 —— 读代码、读文档、看 `package.json` 都不会。
57
+ - 顺带:`.gitignore` 收进 `.npm-cache/`(系统 npm 缓存目录不可写时用的工作区缓存)。
58
+
3
59
  ## 0.11.2
4
60
 
5
61
  适配 DSH **会话格式 v4**(session format v4)——这是一次**不向后兼容**的适配,插件与 DSH 必须一起升级。
package/README.md CHANGED
@@ -72,7 +72,17 @@ dsh plugin --profile web remove dsh-todo-board
72
72
 
73
73
  The messages this plugin injects carry a **producer-owned source** (`{ kind: 'plugin:dsh-todo-board', form: 'notice' }`). Session format **v4** requires exactly that; the retired v3 wrapper `{ kind: 'plugin', plugin: … }` is refused, and the refusal **fails the whole turn**, not just the notice.
74
74
 
75
- `package.json` 的 `engines.dsh` 已写成 `>=0.1.7-rc.2`,装错版本时 npm 会在**安装时**给出警告,而不是等到回合跑起来才报错。反过来,**≤ 0.11.1 在 DSH ≥ 0.1.7 上不能用**。
75
+ > **装错版本没有安装期告警 —— 这是实测的,不是推测。** `package.json` 里的 `engines.dsh` 只是一个**声明**:npm 只校验它认识的引擎名(`node` / `npm`),自定义引擎名不参与检查。实测在 DSH 0.1.5 / 0.1.6 下安装本插件,**不会有** `EBADENGINE` 警告。所以上表请自己对着看。
76
+ >
77
+ > **No install-time warning fires for a mismatched version — measured, not assumed.** `engines.dsh` is a **declaration only**: npm validates the engine names it knows (`node`, `npm`), and a custom name is not checked. Installing this plugin against DSH 0.1.5 / 0.1.6 produces **no** `EBADENGINE` warning.
78
+ >
79
+ > 装错版本的**实际表现是运行时报错,而且报得很直白**:DSH ≥ 0.1.7 会拒绝我们写出的消息,DSH ≤ 0.1.6 那边则没有 v4 的那套校验,两条路都会**带着整个回合一起失败**,原因会写进插件日志。
80
+ >
81
+ > A mismatch shows up as a **runtime failure of the whole turn**, with the reason in the plugin log.
82
+
83
+ npm 上发布过、但**不带**这个适配的版本只有 **0.4.1 / 0.5.0 / 0.6.1**(它们写的是已退休的 v3 wrapper,在 DSH ≥ 0.1.7 上会让整个回合失败);**0.11.2 是第一个带适配的发布版**。旧版本不会自动升级 —— 升级 DSH 之后请一并升级本插件。
84
+
85
+ The only **published** releases without this adaptation are **0.4.1 / 0.5.0 / 0.6.1** (they still write the retired v3 wrapper, which fails the whole turn on DSH ≥ 0.1.7); **0.11.2 was the first release with it**. Releases do not auto-upgrade: after upgrading DSH, upgrade the plugin too.
76
86
 
77
87
  ## 快速上手 / Quick start
78
88
 
Binary file
Binary file
Binary file
Binary file
package/client/client.js CHANGED
@@ -101,7 +101,7 @@ const SKINS = [
101
101
  * host and browser halves of one release are one build. `client-smoke.mjs` pins
102
102
  * the two together, because a footer that lies is worse than no footer.
103
103
  */
104
- const BUILD = '0.11.2'
104
+ const BUILD = '0.11.4'
105
105
 
106
106
  /**
107
107
  * Severity filters in the log view, most severe first.
@@ -1015,8 +1015,23 @@ function foldable(options) {
1015
1015
  // --------------------------------------------------------------- component
1016
1016
 
1017
1017
  function TodoBoard(props) {
1018
- const currentId = props.useSessions((s) => s.current)
1019
- const currentSummary = props.useSessions((s) => (s.current === undefined ? undefined : s.byId[s.current]))
1018
+ // The session list store is `{ ids, byId, phase, projectionsBySession }` — it
1019
+ // has NO `current` key. Reading `s.current` therefore always yielded
1020
+ // `undefined`, and BOTH `currentId` and `cwd` collapsed to `''`. That is what
1021
+ // broke the scope tabs while the row labels stayed correct: the labels come
1022
+ // from the host payload (`dirLabel`), whereas 「当前目录」 compared every row's
1023
+ // `dir` against `''` (nothing can match) and 「当前会话」 compared
1024
+ // `sourceSessionId` against `undefined`. Derive the current session the way the
1025
+ // harness itself does — the summary the main view retains.
1026
+ const currentSummary = props.useSessions((s) => {
1027
+ const byId = s === undefined || s === null ? undefined : s.byId
1028
+ if (byId === undefined || byId === null) return undefined
1029
+ for (const row of Object.values(byId)) {
1030
+ if (row !== null && typeof row === 'object' && ((row.retainedBy ?? {}).mainView ?? 0) > 0) return row
1031
+ }
1032
+ return undefined
1033
+ })
1034
+ const currentId = currentSummary === undefined || currentSummary === null ? undefined : currentSummary.id
1020
1035
  const cwd =
1021
1036
  currentSummary !== undefined && currentSummary !== null && typeof currentSummary.cwd === 'string'
1022
1037
  ? currentSummary.cwd
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-todo-board",
3
- "version": "0.11.2",
3
+ "version": "0.11.4",
4
4
  "description": "跨会话 TODO 板:右上角浮窗、按工作目录分组、可拖动排序;每条待办可选「提醒 / 自动续跑 / 自动新开会话」三档执行模式,截图 Ctrl+V 直接粘贴成附图(派发时作为真正的图片发给模型),可设定本地时间到点才执行,双勾选(AI 完成 / 用户验收)—— 勾上右勾的行会移入下方独立的「已完成」列表,每条待办还能带备注并在面板内直接编辑。三套可切换的界面风格(票据 / 素白 / 紧凑)。长任务可以让模型先拆成步骤再按顺序执行(`/todo <目标>` 或直接粘模板;一次调用写入整份计划、一次审批)。AI 完成一项后自动查找同目录下一条未完成待办并继续执行;AI 改板子一律先经 DSH 原生审批框,板子路由另需浏览器会话凭据。",
5
5
  "private": false,
6
6
  "type": "module",
@@ -22,6 +22,7 @@
22
22
  "lib",
23
23
  "client",
24
24
  "tools",
25
+ "assets",
25
26
  "cordis.patch.yml",
26
27
  "README.md",
27
28
  "CHANGELOG.md",
@@ -170,7 +170,7 @@ UNBROKEN-${'z'.repeat(160)}</div>
170
170
  </div>
171
171
  </div>
172
172
  </div>
173
- <div class="dshtb-foot"><span>v0.11.2</span><button class="dshtb-link">清理</button></div>
173
+ <div class="dshtb-foot"><span>v0.11.4</span><button class="dshtb-link">清理</button></div>
174
174
  </div>\`
175
175
  host.appendChild(root)
176
176
  return root
@@ -34,6 +34,11 @@
34
34
  * 29. the status line is hidden again (build marker and open count disappear)
35
35
  * 30. the mode hint is not rendered (the mode chip goes unexplained)
36
36
  * 31. the mode hint is reworded (the text drifts from what was asked for)
37
+ * 32. the current session is read from a store key that does not exist (both
38
+ * scope tabs go empty while the row labels stay right)
39
+ * 33. any listed session counts as current (the retained flag is ignored)
40
+ * 34. the scope tabs stop narrowing by session
41
+ * 35. the scope tabs stop narrowing by directory
37
42
  *
38
43
  * Patterns are matched against a normalized (LF) copy because the working tree
39
44
  * is checked out with CRLF on Windows, then the replacement is mapped back onto
@@ -277,6 +282,42 @@ const mutants = [
277
282
  from: "'你可以通过点击更改任务执行模式,但不建议任务开始执行后更改',",
278
283
  to: "'点模式标签可以改执行模式。',",
279
284
  },
285
+ {
286
+ // v0.11.4. The scope tabs read the current session off `s.current`, a key the
287
+ // session-list store has never had, so `cwd` and `currentId` both collapsed to
288
+ // `''`/`undefined`: 「当前目录」 compared every row against `''` and 「当前会话」
289
+ // against `undefined`, listing nothing — while the row labels (host payload)
290
+ // stayed correct, which is what made it look like a filter bug rather than a
291
+ // dead read. This is the exact regression.
292
+ name: 'the current session comes from a store key that does not exist (scope tabs go empty)',
293
+ from:
294
+ ' const byId = s === undefined || s === null ? undefined : s.byId\n' +
295
+ ' if (byId === undefined || byId === null) return undefined\n' +
296
+ ' for (const row of Object.values(byId)) {\n' +
297
+ ' if (row !== null && typeof row === \'object\' && ((row.retainedBy ?? {}).mainView ?? 0) > 0) return row\n' +
298
+ ' }\n' +
299
+ ' return undefined',
300
+ to:
301
+ ' const byId = s === undefined || s === null ? undefined : s.byId\n' +
302
+ ' if (byId === undefined || byId === null) return undefined\n' +
303
+ ' return byId[s.current]',
304
+ },
305
+ {
306
+ name: 'any listed session counts as current (the retained flag is ignored)',
307
+ from:
308
+ " if (row !== null && typeof row === 'object' && ((row.retainedBy ?? {}).mainView ?? 0) > 0) return row",
309
+ to: " if (row !== null && typeof row === 'object') return row",
310
+ },
311
+ {
312
+ name: 'the scope tabs stop narrowing by session',
313
+ from: ' const bySession = todos.filter((t) => t.sourceSessionId === currentId)',
314
+ to: ' const bySession = todos.filter(() => true)',
315
+ },
316
+ {
317
+ name: 'the scope tabs stop narrowing by directory',
318
+ from: ' const byDir = todos.filter((t) => t.dir === cwdKey)',
319
+ to: ' const byDir = todos.filter(() => true)',
320
+ },
280
321
  ]
281
322
 
282
323
  /** Apply one mutant to CRLF text by matching and replacing on the LF form. */
@@ -455,14 +455,43 @@ function findByText(node, needle) {
455
455
  return out
456
456
  }
457
457
 
458
+ /**
459
+ * The session-list store, shaped the way the harness really sends it.
460
+ *
461
+ * `{ ids, byId, phase, projectionsBySession }` — there is **no** `current` key.
462
+ * This fixture used to spell one anyway, and that is why the scope tabs could be
463
+ * broken in the browser for several releases while this suite stayed green: the
464
+ * panel read `s.current`, which is `undefined` in production and `'s1'` here, so
465
+ * the fixture answered a question the real store never answers. A fixture that
466
+ * invents a field is worse than no fixture — it converts a live bug into a
467
+ * passing test.
468
+ *
469
+ * The current session is the row the main view **retains**, which is how the
470
+ * harness itself derives it (`dsh-client-ui-layout`, `-workspace`, `-cordis`,
471
+ * `-settings-general`, `-session` all scan for `retainedBy.mainView > 0`).
472
+ */
473
+ function sessionsSnapshot() {
474
+ return {
475
+ ids: ['s2', 's1'],
476
+ byId: {
477
+ // Listed, but NO view retains it — and deliberately first, so "stop at the
478
+ // first row" is a distinguishable bug from "find the row the main view
479
+ // retains". With a single-session fixture those two are the same thing, and
480
+ // the test would pass for a reason it never checked.
481
+ s2: { id: 's2', cwd: 'D:\\somewhere\\else', title: '后台会话', retainedBy: {} },
482
+ s1: { id: 's1', cwd: CWD, title: '会话', retainedBy: { mainView: 1 } },
483
+ },
484
+ phase: 'ready',
485
+ projectionsBySession: {},
486
+ }
487
+ }
488
+
458
489
  function render() {
459
490
  cursor = 0
460
491
  rendering = true
461
492
  let tree
462
493
  try {
463
- tree = TodoBoard({
464
- useSessions: (select) => select({ current: 's1', byId: { s1: { cwd: CWD, title: '会话' } } }),
465
- })
494
+ tree = TodoBoard({ useSessions: (select) => select(sessionsSnapshot()) })
466
495
  } finally {
467
496
  rendering = false
468
497
  }
@@ -945,7 +974,66 @@ assert.equal(calls[calls.length - 1].patch.schedule, '', 'clearing sends an empt
945
974
  assert.equal(calls.length, beforeClear + 1, 'and sends exactly one request')
946
975
  console.log('rowsech OK')
947
976
 
977
+ // -- the scope tabs actually scope ----------------------------------------
978
+ //
979
+ // The bug this exists for: `cwd` and `currentId` were both read off a store key
980
+ // that does not exist (`s.current`), so they collapsed to `''` / `undefined`.
981
+ // 「当前目录」 then compared every row's `dir` against `''`, and 「当前会话」
982
+ // compared `sourceSessionId` against `undefined` — neither can ever match, so
983
+ // both tabs listed nothing while the row labels (which come from the host
984
+ // payload) kept showing the right directory. The fixture is what hid it: it
985
+ // spelled a `current` field the real store never sends.
986
+ //
987
+ // So this test asserts on ROWS, not on chrome: a tab that is highlighted but
988
+ // lists nothing is exactly the failure mode being guarded.
989
+ snapshot.todos = [
990
+ todo({ id: 'both', title: '同目录同会话', order: 0 }),
991
+ todo({ id: 'dir', title: '同目录异会话', order: 1, sourceSessionId: 's2' }),
992
+ todo({
993
+ id: 'other',
994
+ title: '异目录同会话',
995
+ order: 2,
996
+ dir: 'd:\\elsewhere',
997
+ dirPath: 'D:\\elsewhere',
998
+ }),
999
+ ]
1000
+ await new Promise((resolve) => setTimeout(resolve, 0))
1001
+ tree = render()
1002
+
1003
+ /** Row titles in the OPEN list. `dshtb-t` is the title node, so chips and facts cannot leak in. */
1004
+ const openTitles = () => findByClass(tree, 'dshtb-t').map(textOf)
1005
+ const scopeTab = (label) =>
1006
+ findByClass(tree, 'dshtb-seg')[0].children.filter((node) => textOf(node).includes(label))[0]
1007
+
1008
+ // The default tab is 「当前目录」, and it has to agree with what the rows say.
1009
+ assert.deepEqual(
1010
+ openTitles(),
1011
+ ['同目录同会话', '同目录异会话'],
1012
+ 'the default 「当前目录」 tab lists this directory\'s rows — not nothing, and not everything',
1013
+ )
1014
+ assert.ok(
1015
+ textOf(scopeTab('当前目录')).includes('2'),
1016
+ 'and its count is this directory\'s, not zero',
1017
+ )
1018
+
1019
+ tree = click(scopeTab('当前会话'))
1020
+ assert.deepEqual(
1021
+ openTitles(),
1022
+ ['同目录同会话', '异目录同会话'],
1023
+ '「当前会话」 narrows by source session instead of matching nothing',
1024
+ )
1025
+
1026
+ tree = click(scopeTab('全部'))
1027
+ assert.deepEqual(
1028
+ openTitles(),
1029
+ ['同目录同会话', '同目录异会话', '异目录同会话'],
1030
+ '「全部」 is the union, so the two tabs above really were narrowing',
1031
+ )
948
1032
 
1033
+ // Back to the default: the next section asserts on the 「当前目录」 empty wording.
1034
+ tree = click(scopeTab('当前目录'))
1035
+ assert.deepEqual(openTitles(), ['同目录同会话', '同目录异会话'], 'and the tabs still work after switching')
1036
+ console.log('scope OK')
949
1037
 
950
1038
  snapshot.todos = [todo({ id: 'c', title: '已验收的', verified: true })]
951
1039
  await new Promise((resolve) => setTimeout(resolve, 0))
@@ -1362,6 +1450,15 @@ await new Promise((resolve) => setTimeout(resolve, 0))
1362
1450
  const created = calls[calls.length - 1]
1363
1451
  assert.equal(calls.length, beforeAdd + 1, 'adding sends exactly one request')
1364
1452
  assert.equal(created.action, 'create', 'through the create action')
1453
+ // The same dead read that emptied the scope tabs also emptied these three: with
1454
+ // `cwd`/`currentId` collapsed, a row created from the panel was filed under NO
1455
+ // directory (`dir: ''`) and NO origin session — and that is PERSISTED, so the
1456
+ // row then never matches 「当前目录」, never shows a session chip, and has no
1457
+ // session to continue in. A code fix cannot repair rows already written, so it
1458
+ // has to be pinned at the boundary where they are written.
1459
+ assert.equal(created.dir, CWD, 'a row created with no directory typed is filed under the session cwd')
1460
+ assert.equal(created.sessionId, 's1', 'and carries the origin session it came from')
1461
+ assert.equal(created.sessionTitle, '会话', 'with that session\'s title, so the chip can name it')
1365
1462
  assert.equal(created.images.length, room, 'carrying every pasted image: ' + created.images.length)
1366
1463
  assert.ok(
1367
1464
  created.images.every((image) => typeof image.data === 'string' && image.data !== '' && typeof image.mediaType === 'string' && image.mediaType !== ''),