dsh-trajectory-traceview-plus 0.11.8 → 0.11.10

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,30 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.11.10 — 详情面板折叠(2026-11-29)
4
+
5
+ - **详情面板打开一条 1 MB 消息要 0.5 秒——这次两全了。** 之前 README 把它写成明示取舍
6
+ ("查看时不截断"),实测 488 ms、单条消息的 `textContent` 就有 1,000,042 字符。现在
7
+ 面板先渲染前 50,000 字符,并给一个「显示全文(950000 字符)」按钮:打开 **19 ms**,
8
+ 展开约 430 ms,而**被截断的只是 DOM,不是数据**——复制和导出始终是全文。
9
+ 探针 23q 守住三件事:打开 < 200 ms、按钮如实报出隐藏了多少、展开后全文可回读;
10
+ 变异(去掉折叠)→ 红。
11
+ - **同一处还挖出一个我自己的 bug**:给 `.dstv_foldBtn` 加样式时把真实换行插进了 CSS
12
+ 字符串字面量,模块直接语法错误。而浏览器里的表现是 `Cannot read properties of undefined
13
+ (reading 'apply')`——加载器在模块加载失败后调用 `exports.apply`。**报错信息指向的地方
14
+ 和真正出错的地方差了约 6000 行**,最后是用 node 直接加载模块才看到 `SyntaxError`。
15
+
16
+ ## 0.11.9 — 凭证覆盖断言本身(2026-11-29)
17
+
18
+ - **凭证第一版留了最该堵的洞。** 它只哈希 `src/*.js`,于是**把断言改弱完全不被发现**——
19
+ 删掉一百条断言,凭证照样绿。这个洞在写完当天就被踩到:0.11.8 里改探针文件,凭证毫无反应。
20
+ 摘要现在抽到 `scripts/probe-digest.mjs`,覆盖 15 个文件(`src/*.js`、夹具、五个
21
+ `probe*.js`、两个驱动脚本),两边 import 同一个函数。
22
+ - **两处"验证过但没断言"的行为补上守卫**:搜索计数随流式 partial 增减(23o)、
23
+ 回放在中途到达新事件时继续前进(23p)。两者都做过变异验证
24
+ (`matches` 去掉 `stations` 依赖 → 23o 红;回放不推进 → 23p 红)。
25
+ 写这两条时我自己先把上下文留脏了——用局部快照收尾,坑掉了后面的英文界面组
26
+ (`no step station to open the English detail panel on`),已改为恢复共享快照。
27
+
3
28
  ## 0.11.8 — 探针凭证与解耦(2026-11-28)
4
29
 
5
30
  **运行时(`src/`、`lib/`)与 0.11.7 逐字节相同**,这一版改的是"怎么证明它没问题"。
package/README.en.md CHANGED
@@ -136,7 +136,7 @@ dsh-trajectory-traceview-plus/ # repo root (directory name == npm package name
136
136
  Install from npm (recommended — **pin the exact version**):
137
137
 
138
138
  ```powershell
139
- dsh plugin --profile web add dsh-trajectory-traceview-plus@0.11.8
139
+ dsh plugin --profile web add dsh-trajectory-traceview-plus@0.11.10
140
140
  ```
141
141
 
142
142
  > **Why not `@latest`**: `dsh plugin` forwards to pnpm, and **pnpm 12 ships a supply-chain delay** (`minimumReleaseAge`, default **1440 minutes = 24 hours**): a version published less than a day ago is not selected by `@latest`, and pnpm **silently falls back to the previous release** — no warning at all. Right after 0.11.0 was published, `pnpm add pkg@latest` installed 0.10.0, which the newer DSH hosts skip entirely. An exact version has no such ambiguity (verified with both cold and warm caches).
@@ -148,10 +148,10 @@ dsh plugin --profile web add dsh-trajectory-traceview-plus@0.11.8
148
148
  Install from GitHub (**always pin the tag**):
149
149
 
150
150
  ```powershell
151
- dsh plugin --profile web add "github:MisonL/dsh-trajectory-traceview-plus#v0.11.8"
151
+ dsh plugin --profile web add "github:MisonL/dsh-trajectory-traceview-plus#v0.11.10"
152
152
  ```
153
153
 
154
- > **Why the `#v0.11.8` matters**: a `github:` spec without a ref installs the **default branch HEAD**, not any released version. This repository keeps committing after a release (v0.11.0 was followed by five docs/scripts commits), so an unpinned install can hand you different code tomorrow while still reporting version 0.11.0. Pinning the tag is what makes "installed" and "released" the same code.
154
+ > **Why the `#v0.11.10` matters**: a `github:` spec without a ref installs the **default branch HEAD**, not any released version. This repository keeps committing after a release (v0.11.0 was followed by five docs/scripts commits), so an unpinned install can hand you different code tomorrow while still reporting version 0.11.0. Pinning the tag is what makes "installed" and "released" the same code.
155
155
 
156
156
  Then **restart `dsh web`** to take effect.
157
157
 
@@ -268,8 +268,8 @@ The tests run the helper region against mock snapshots covering: tree building /
268
268
  **What needs a real browser** (`react-dom/server` cannot see scroll, focus, clipboard, intervals or layout):
269
269
 
270
270
  ```powershell
271
- node scripts/browser-check.mjs # builds the harness; 314 assertions over 48 recorded groups
272
- node scripts/browser-check.mjs --shots # saves screenshots and adds 1 more group / 3 assertions: 375px overflow (49 total)
271
+ node scripts/browser-check.mjs # builds the harness; 327 assertions over 51 recorded groups
272
+ node scripts/browser-check.mjs --shots # saves screenshots and adds 1 more group / 3 assertions: 375px overflow (52 total)
273
273
  ```
274
274
 
275
275
  It needs `agent-browser` (Chrome via CDP). **Deliberately not in CI**: adding a browser to the runner is more moving parts than the check is worth, and a flaky browser job trains people to ignore red builds. Run it locally before releasing.
@@ -332,18 +332,20 @@ node scripts/browser-check.mjs # 4.5 run the real browser probe (needs
332
332
  npm run check # 5. the 11 local gates; all green before going further
333
333
  git add -A; git commit -m "..." # 6.
334
334
  git push origin main # 7.
335
- git tag -a v0.11.8 -m "..." # 8.
336
- git push origin v0.11.8 # 9.
335
+ git tag -a v0.11.10 -m "..." # 8.
336
+ git push origin v0.11.10 # 9.
337
337
  npm publish # 10. runs prepublishOnly -> the whole check again
338
- gh release create v0.11.8 --notes-file … # 11. the badge reads the Release, not the tag
338
+ gh release create v0.11.10 --notes-file … # 11. the badge reads the Release, not the tag
339
339
 
340
340
  node scripts/release-status.mjs # 12. do all four agree? (tag / Release / npm metadata / tarball)
341
341
  ```
342
342
 
343
343
  **Touch `src/` and you must rerun step 4.5**, or the receipt gate goes red:
344
- `probe-receipt-check` compares the source digest inside `test/browser/probe-receipt.json`
345
- against the current `src/` and fails with `STALE — src/ changed after the probe last
346
- passed`. The reason is concrete: the browser probe cannot run in CI (it needs a real
344
+ `probe-receipt-check` compares the digest inside `test/browser/probe-receipt.json` against
345
+ the current tree and fails with `STALE — the probe inputs changed…`. The digest covers 15
346
+ files (`src/*.js`, `fixture.js`, the five `probe*.js`, two driver scripts) — **including
347
+ the assertions**, since a src-only digest stayed green while someone deleted a hundred of
348
+ them. The reason is concrete: the browser probe cannot run in CI (it needs a real
347
349
  Chrome), so "the probe passed" is one step away from being a claim about code that no
348
350
  longer exists. It proves the probe passed **once, against this exact src/**; it does not
349
351
  prove the probe would pass now, and it does not prove anyone read the result. It fills a
package/README.md CHANGED
@@ -139,7 +139,7 @@ dsh-trajectory-traceview-plus/ # 仓库根(目录名 = npm 包名)
139
139
  从 npm 安装(推荐,**写死版本号**):
140
140
 
141
141
  ```powershell
142
- dsh plugin --profile web add dsh-trajectory-traceview-plus@0.11.8
142
+ dsh plugin --profile web add dsh-trajectory-traceview-plus@0.11.10
143
143
  ```
144
144
 
145
145
  > **为什么不用 `@latest`**:`dsh plugin` 底层是 pnpm,而 **pnpm 12 有供应链延迟保护**
@@ -160,10 +160,10 @@ dsh plugin --profile web add dsh-trajectory-traceview-plus@0.11.8
160
160
  从 GitHub 安装(**必须带 tag**):
161
161
 
162
162
  ```powershell
163
- dsh plugin --profile web add "github:MisonL/dsh-trajectory-traceview-plus#v0.11.8"
163
+ dsh plugin --profile web add "github:MisonL/dsh-trajectory-traceview-plus#v0.11.10"
164
164
  ```
165
165
 
166
- > **为什么必须带 `#v0.11.8`**:`github:` 规格不带 ref 时装的是**默认分支的 HEAD**,
166
+ > **为什么必须带 `#v0.11.10`**:`github:` 规格不带 ref 时装的是**默认分支的 HEAD**,
167
167
  > 不是任何发布版本。而这个仓库在发版后还会继续提交(本轮 v0.11.0 之后就有 5 个
168
168
  > 文档/脚本提交),所以"不带 ref"装到的东西**明天可能是另一个样子**,而版本号
169
169
  > 仍写着 0.11.0。带 tag 才能让"装到的"和"发布过的"是同一份代码。
@@ -286,8 +286,8 @@ npm test # 只跑 smoke
286
286
  **需要真实浏览器的部分**(`react-dom/server` 测不到滚动、焦点、剪贴板、定时器、响应式):
287
287
 
288
288
  ```powershell
289
- node scripts/browser-check.mjs # 起 harness,跑 314 条断言 / 记录 48 组观测
290
- node scripts/browser-check.mjs --shots # 另存截图,并另加 1 组 / 3 条断言(375px 溢出,共 49 组)
289
+ node scripts/browser-check.mjs # 起 harness,跑 327 条断言 / 记录 51 组观测
290
+ node scripts/browser-check.mjs --shots # 另存截图,并另加 1 组 / 3 条断言(375px 溢出,共 52 组)
291
291
  ```
292
292
 
293
293
  它需要 `agent-browser`(Chrome via CDP)。**故意不进 CI**:把浏览器塞进 runner 的
@@ -306,7 +306,9 @@ node scripts/browser-check.mjs --shots # 另存截图,并另加 1 组 / 3 条
306
306
  - **版本不兼容会大声说**:如果 DSH 升级后字段名或节点类型变了,头部显示 `⚠ N 条记录无法识别 [类型名]`;若**一条都认不出**,显示「无法识别当前会话的轨迹数据格式」并列出原因码——**不会伪装成"暂无数据"或一份看起来正常的残缺轨迹**。
307
307
  - **超长文本有明确取舍**:站点卡是缩略图,正文封顶 20,000 字符、tooltip 封顶 300(末尾补 `…`)——
308
308
  不封顶时一条 1 MB 消息会整条塞进 DOM(实测单卡 1,575 ms、1,000,007 字符)。**完整内容不丢**:
309
- 复制、详情面板、导出都拿到原文。详情面板刻意不截断,所以打开单条 1 MB 消息约 0.5 秒(实测 541 ms)。
309
+ 复制、详情面板、导出都拿到原文。详情面板对超长正文先渲染前 50,000 字符并给一个
310
+ 「显示全文(N 字符)」按钮——**被截断的只是 DOM,不是数据**:打开单条 1 MB 消息从
311
+ 实测 488 ms 降到 19 ms,点按钮展开全文约 430 ms,复制和导出始终是全文。
310
312
  - **不冤枉宿主**:`kind: "unknown"` 是契约里**有名字**的节点类型(宿主明确表示"这条事件我不建模"),所以它被当成一等站点画出来,标出事件类型与原始数据,**不计入"版本不兼容"**。只有真正没见过的节点类型才报警。这条区别很重要:一个陌生事件不该让整棵树改口说"格式不认识"。
311
313
 
312
314
  `engines.dsh` 是 `>=0.2.2-rc.2 <0.2.3-0`——**只覆盖 0.2.2 这一条实测过的线**,不跨 minor。旧钉版 `=0.2.1-rc.5`、`=0.2.2-rc.2` 的历史结论保留在 `docs/DESIGN.md` §12.25–§12.27、§13.43。
@@ -357,17 +359,18 @@ node scripts/browser-check.mjs # 4.5 跑真正的浏览器探针(需
357
359
  npm run check # 5. 11 步门禁,全绿再往下(含凭证校验)
358
360
  git add -A; git commit -m "..." # 6.
359
361
  git push origin main # 7.
360
- git tag -a v0.11.8 -m "..." # 8.
361
- git push origin v0.11.8 # 9.
362
+ git tag -a v0.11.10 -m "..." # 8.
363
+ git push origin v0.11.10 # 9.
362
364
  npm publish # 10. 触发 prepublishOnly → 再跑一遍 check
363
- gh release create v0.11.8 --notes-file … # 11. 徽章读的是 Release,不是 tag
365
+ gh release create v0.11.10 --notes-file … # 11. 徽章读的是 Release,不是 tag
364
366
 
365
367
  node scripts/release-status.mjs # 12. 四处对齐了吗?(tag / Release / npm 元数据 / tarball)
366
368
  ```
367
369
 
368
- **改过 `src/` 就必须重跑步骤 4.5**,否则步骤 5 会红:`probe-receipt-check` 拿
369
- `test/browser/probe-receipt.json` 里的源码摘要和当前 `src/` 对比,不一致就报
370
- `STALE — src/ changed after the probe last passed`。这条守卫存在的原因很具体:浏览器探针
370
+ **改过 `src/`、夹具或任何一个探针文件,就必须重跑步骤 4.5**,否则步骤 5 会红:
371
+ `probe-receipt-check` 拿 `test/browser/probe-receipt.json` 里的摘要和当前树对比,不一致就报
372
+ `STALE — the probe inputs changed…`。摘要覆盖 15 个文件(`src/*.js`、`fixture.js`、
373
+ 五个 `probe*.js`、两个驱动脚本)——**包括断言本身**,否则"删掉一百条断言"也能让凭证保持绿色。这条守卫存在的原因很具体:浏览器探针
371
374
  跑不进 CI(需要真 Chrome),于是"探针通过了"很容易变成一句关于**已经不存在的代码**的话。
372
375
  它只证明"某个 src/ 摘要确切等于当前的树、探针在那上面通过过一次",**不证明探针现在还会通过**,
373
376
  也不证明有人看过结果——是补上一个缺失的信号,不是测试的替代品。
package/docs/DESIGN.md CHANGED
@@ -9728,10 +9728,26 @@ panel text: Trace ViewUserStepToolCompactionerror⏮⇤◀…
9728
9728
 
9729
9729
  **它证明什么、不证明什么**(写在这里,因为这类守卫最容易变成"有它就安心"):
9730
9730
 
9731
- - 证明:探针在某个 src/ 摘要上通过过,而那个摘要与当前的树相同。
9731
+ - 证明:探针在某个摘要上通过过,而那个摘要与当前的树相同。
9732
9732
  - 不证明:探针现在还会通过(只有真的跑才知道)。
9733
9733
  - 不证明:有人看过结果。凭证是机器写的,谁都能改文件——它是防遗忘,不是防伪造。
9734
9734
 
9735
+ **第一版凭证自己留了最该堵的那个洞。** 它只哈希 `src/*.js`,于是**把断言改弱完全
9736
+ 不被发现**:删掉一百条断言,凭证照样绿——它记录的是"某个探针通过了",不是"这个探针通过了"。
9737
+ 而这个洞在写完之后立刻就被踩到:0.11.8 里我把 `probe-detail2/3.js` 改成自重建,凭证毫无反应。
9738
+
9739
+ 现在摘要的定义抽到 `scripts/probe-digest.mjs`,覆盖 15 个文件:`src/*.js`(被测代码)、
9740
+ `test/browser/fixture.js`(宿主桩——夹具错了就什么都没测)、五个 `probe*.js`(断言本身)、
9741
+ 以及 `browser-check.mjs` / `browser-harness.mjs`(驱动)。两边都 import 同一个函数:
9742
+ 分开算会漂移,而漂移看起来**恰好**像"凭证过期"——对一个专门保证"证据与树相符"的守卫来说,
9743
+ 这是最糟的失败形态。
9744
+
9745
+ 刻意**不**纳入:`probe-receipt-check.mjs` 自己(改个错误文案就得重跑探针,荒唐),
9746
+ 以及其余门禁脚本(它们校验的是探针的**输出**,且各自有门禁)。
9747
+
9748
+ 验证:往 `probe-detail3.js` 末尾追加一个空行 → `STALE — the probe inputs changed…`;
9749
+ 恢复 → OK。改 `probe-receipt-check.mjs` 的文案 → 仍然 OK(符合预期)。
9750
+
9735
9751
  首次接入时做过的验证:给 `src/00-locale.js` 追加一个换行 → `probe-receipt-check` 退出码 1,
9736
9752
  打印 `STALE — src/ changed after the probe last passed`;恢复后退出码 0。
9737
9753
 
@@ -10776,6 +10792,9 @@ boundary: false ← 没有渲染失败卡
10776
10792
  | 27 | 生成中的步骤排到本轮第一步之前 | partial 时间戳用轮次最早 seq + 0.5 | `PARTIALORDER1`(变异 → 红) |
10777
10793
  | 28 | 导出表头少了「工具总耗时」 | 屏幕五项、导出四项 | `EXPORTKPI1` + 探针 23n(变异 → 红) |
10778
10794
  | 29 | 探针涨到 37 秒,变异验证变成「无法解析」 | `eval` 30 秒上限,超时不是失败 | 拆出 `probe-detail3.js`;`healthySnap` 移进 IIFE |
10795
+ | 30 | 凭证只覆盖 `src/`,弱化断言不被发现 | 删掉一百条断言仍绿 | 摘要覆盖 15 个文件(`probe-digest.mjs`) |
10796
+ | 31 | 搜索计数/回放推进没有守卫 | 验证过但没写断言 | 探针 23o / 23p(均做过变异验证) |
10797
+ | 32 | 详情面板打开 1 MB 消息 488 ms | 全文当 markdown 一次灌进 DOM | 折叠到 50k + 「显示全文」,探针 23q(变异 → 红) |
10779
10798
 
10780
10799
  ### 13.82.9 夹具与官方契约的一处偏差:`callSchemas` 是 Map,不是对象
10781
10800
 
@@ -39,6 +39,7 @@
39
39
  - `scripts/guard-check.mjs`
40
40
  - `scripts/harness-stamp.mjs`
41
41
  - `scripts/path-leak-check.mjs`
42
+ - `scripts/probe-digest.mjs`
42
43
  - `scripts/probe-receipt-check.mjs`
43
44
  - `scripts/provenance.mjs`
44
45
  - `scripts/readme-numbers.mjs`
@@ -61,7 +62,7 @@
61
62
 
62
63
  ## 二、`lib/client.js` 函数级
63
64
 
64
- 上游 24 个函数:**9 个原样保留、15 个被修改、0 个被删除**;本仓**新增 53 个**。
65
+ 上游 24 个函数:**9 个原样保留、15 个被修改、0 个被删除**;本仓**新增 54 个**。
65
66
 
66
67
  ### 原样保留(9)
67
68
 
@@ -97,10 +98,11 @@
97
98
  - `subDetailOf`
98
99
  - `textOfContent`
99
100
 
100
- ### 本仓新增(53)
101
+ ### 本仓新增(54)
101
102
 
102
103
  上游完全没有:
103
104
 
105
+ - `FoldedMarkdown`
104
106
  - `MarkdownText`
105
107
  - `anchorCoveredByWindow`
106
108
  - `anchorLoadTarget`
package/lib/client.js CHANGED
@@ -110,6 +110,7 @@ window.__ModuleLoader__.load({
110
110
  "detail.items": "项",
111
111
  "detail.request": "请求配置",
112
112
  "detail.systemPrompt": "系统提示",
113
+ "detail.showAll": "显示全文",
113
114
  "detail.systemOutside": "来自窗口外的系统事件 e{seq}",
114
115
  "detail.systemNone": "(当前窗口内没有系统提示)",
115
116
  "detail.toolsCatalog": "工具目录",
@@ -297,6 +298,7 @@ window.__ModuleLoader__.load({
297
298
  "detail.items": "items",
298
299
  "detail.request": "Request config",
299
300
  "detail.systemPrompt": "System prompt",
301
+ "detail.showAll": "Show all",
300
302
  "detail.systemOutside": "from system event e{seq} outside the window",
301
303
  "detail.systemNone": "(no system prompt in this window)",
302
304
  "detail.toolsCatalog": "Tool catalog",
@@ -580,6 +582,11 @@ window.__ModuleLoader__.load({
580
582
  // printed the source, so users read "**0.9.13**" and "# heading" literally.
581
583
  // Blocks below restore the visual hierarchy the transcript actually has.
582
584
  ".dstv_dMarkdown{white-space:normal}",
585
+ // The detail panel folds very long bodies (DETAIL_TEXT_MAX); this is the one
586
+ // control that brings the rest back, so it must be a real, focusable button.
587
+ ".dstv_foldBtn{margin-top:8px;padding:4px 10px;font:inherit;font-size:11px;color:var(--dstv-accent);background:transparent;border:1px solid var(--dstv-border);border-radius:6px;cursor:pointer}",
588
+ ".dstv_foldBtn:hover{background:var(--dstv-hover)}",
589
+ ".dstv_foldBtn:focus-visible{outline:2px solid var(--dstv-accent);outline-offset:2px}",
583
590
  // A caption + body card reads as a document section; without it the label and
584
591
  // the prose collapse into one paragraph line.
585
592
  ".dstv_dSectionBody{gap:4px;padding:8px 10px;border:1px solid var(--dsw-alias-border-l2);border-radius:9px;background:var(--dsw-alias-bg-layer-2)}",
@@ -3774,6 +3781,40 @@ window.__ModuleLoader__.load({
3774
3781
  return p.text;
3775
3782
  });
3776
3783
  }
3784
+ /**
3785
+ * How much of a message the detail panel renders before offering "show all".
3786
+ *
3787
+ * The panel deliberately does NOT truncate the DATA — copying, exporting and the
3788
+ * tooltip all still use the whole string. What it truncates is the DOM: a 1 MB
3789
+ * message was parsed as markdown and poured into a single text node, and opening
3790
+ * its detail panel measured 488 ms (1,000,042 characters of `textContent`).
3791
+ * 50,000 keeps the common case (long log dump, stack trace) intact and costs
3792
+ * ~30 ms; the button makes the rest one click away, so nothing is lost.
3793
+ */
3794
+ const DETAIL_TEXT_MAX = 50000;
3795
+
3796
+ /** Long text rendered as markdown, with an explicit "show all" affordance. */
3797
+ function FoldedMarkdown({ text, expandLabel, suffix }) {
3798
+ const expandedState = (0, react.useState)(false);
3799
+ const expanded = expandedState[0];
3800
+ const setExpanded = expandedState[1];
3801
+ const value = typeof text === "string" ? text : "";
3802
+ const long = value.length > DETAIL_TEXT_MAX;
3803
+ if (!long || expanded) return jsx(MarkdownText, { text: value }, long ? "mdAll" : "md");
3804
+ return jsxs("div", { children: [
3805
+ jsx(MarkdownText, { text: value.slice(0, DETAIL_TEXT_MAX) }, "mdPart"),
3806
+ jsx("button", {
3807
+ type: "button",
3808
+ className: "dstv_foldBtn",
3809
+ // The count is in the label so a screen-reader user knows how much is hidden
3810
+ // before deciding to render it.
3811
+ "aria-expanded": "false",
3812
+ onClick: () => setExpanded(true),
3813
+ children: `${expandLabel} (${value.length - DETAIL_TEXT_MAX} ${suffix})`
3814
+ }, "foldBtn")
3815
+ ] }, "foldWrap");
3816
+ }
3817
+
3777
3818
  function MarkdownText({ text }) {
3778
3819
  const blocks = (0, react.useMemo)(() => mdBlocks(text), [text]);
3779
3820
  const nodes = blocks.map((b, i) => {
@@ -5682,7 +5723,7 @@ window.__ModuleLoader__.load({
5682
5723
  // Markdown too: users paste code blocks and lists just as often.
5683
5724
  return jsxs("div", { className: "dstv_dBody", children: jsxs("div", { className: "dstv_dSection dstv_dSectionBody", children: [
5684
5725
  jsx("span", { className: "dstv_dLabel", children: s.who }, "dLbl"),
5685
- jsx("div", { className: "dstv_dText dstv_dMarkdown", children: s.text !== "" ? jsx(MarkdownText, { text: s.text }, "uMd") : "…" }, "dTxt")
5726
+ jsx("div", { className: "dstv_dText dstv_dMarkdown", children: s.text !== "" ? jsx(FoldedMarkdown, { text: s.text, expandLabel: t("detail.showAll"), suffix: t("detail.chars") }, "uMd") : "…" }, "dTxt")
5686
5727
  ] }) });
5687
5728
  }
5688
5729
  if (s.kind === "step") {
@@ -5695,9 +5736,9 @@ window.__ModuleLoader__.load({
5695
5736
  jsx("span", { className: "dstv_dLabel", children: t("node.assistant") }, "aLbl"),
5696
5737
  cell.thinking !== "" ? jsxs("details", { className: "dstv_det", open: false, children: [
5697
5738
  jsx("summary", { children: [`💭 ${t("chip.thinking")}`, jsx("span", { className: "sub", children: String(cell.thinking.length) }, "aThLen")] }, "aThSum"),
5698
- jsx("div", { className: "inner", children: jsx("div", { className: "dstv_dText sec", children: jsx(MarkdownText, { text: cell.thinking }, "aThMd") }, "aThText") }, "aThInner")
5739
+ jsx("div", { className: "inner", children: jsx("div", { className: "dstv_dText sec", children: jsx(FoldedMarkdown, { text: cell.thinking, expandLabel: t("detail.showAll"), suffix: t("detail.chars") }, "aThMd") }, "aThText") }, "aThInner")
5699
5740
  ] }, `dth${cell.id}`) : null,
5700
- cell.text !== "" ? jsx("div", { className: "dstv_dText dstv_dMarkdown", children: jsx(MarkdownText, { text: cell.text }, "aMd") }, "aText") : null
5741
+ cell.text !== "" ? jsx("div", { className: "dstv_dText dstv_dMarkdown", children: jsx(FoldedMarkdown, { text: cell.text, expandLabel: t("detail.showAll"), suffix: t("detail.chars") }, "aMd") }, "aText") : null
5701
5742
  ] }, `da${cell.id}`);
5702
5743
  }
5703
5744
  if (cell.kind === "tool") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-trajectory-traceview-plus",
3
- "version": "0.11.8",
3
+ "version": "0.11.10",
4
4
  "description": "轨迹视图增强版(Plus):在「轨迹」标签旁新增可回放的横向时间轴——minimap、窗口内检索(显式标注覆盖边界)、回放、轮次跳转、跟随模式、历史分页、步骤/子调用耗时与吞吐、时钟轴切换、稳定锚点复制与深链、孤立工具结果站点、提示词变更对比、原始请求分析与 Markdown 导出。基于 AFAP/dsh-trajectory-traceview (MIT) 改造。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -11,7 +11,7 @@
11
11
  * suite: the smoke suite must stay runnable without a browser.
12
12
  */
13
13
  import { spawnSync } from "node:child_process";
14
- import { createHash } from "node:crypto";
14
+ import { digestProbeInputs } from "./probe-digest.mjs";
15
15
  import fs from "node:fs";
16
16
  import path from "node:path";
17
17
 
@@ -116,12 +116,12 @@ if (parsed.failures.length === 0) {
116
116
  // - a stale probe run was used to justify a commit while src/ had moved on.
117
117
  // `npm run check` (and therefore `prepublishOnly`) now refuses to be green unless
118
118
  // this receipt matches a digest of src/. It is not proof; it is the missing signal.
119
- const srcDigest = createHash("sha256");
120
- for (const f of fs.readdirSync(path.join(root, "src")).sort()) {
121
- if (f.endsWith(".js")) srcDigest.update(f + "\u0000" + fs.readFileSync(path.join(root, "src", f)) + "\u0000");
122
- }
119
+ // Covers src/ AND the test files themselves (see scripts/probe-digest.mjs). The
120
+ // src-only version left the worst hole open: weakening an assertion changed nothing,
121
+ // so deleting 100 of them kept this receipt green.
122
+ const srcDigest = digestProbeInputs(root);
123
123
  const receipt = {
124
- src_digest: srcDigest.digest("hex"),
124
+ src_digest: srcDigest,
125
125
  groups,
126
126
  ran_at: new Date().toISOString()
127
127
  };
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * One definition of "what the browser probe actually verified".
4
+ *
5
+ * USED BY BOTH SIDES. `browser-check.mjs` stamps the digest into
6
+ * `test/browser/probe-receipt.json` after a PASS; `probe-receipt-check.mjs` recomputes it.
7
+ * If the two computed it separately they would drift, and the drift would look exactly
8
+ * like a stale receipt — the worst possible failure mode for a guard whose whole job is
9
+ * "the evidence matches the tree".
10
+ *
11
+ * WHY THE TEST FILES ARE IN HERE. The first version hashed `src/*.js` only, which left
12
+ * the one hole that matters most: WEAKENING AN ASSERTION changed nothing, so deleting
13
+ * 100 assertions kept the receipt green. `fixture.js` is the host stub (a wrong fixture
14
+ * tests nothing), the `probe*.js` files hold the assertions, and the two scripts are the
15
+ * driver. All of them are part of the claim "the probe passed", so all of them are in the
16
+ * digest.
17
+ *
18
+ * NOT INCLUDED, deliberately: `scripts/readme-numbers.mjs` and the other gates. They
19
+ * verify the probe's OUTPUT (counts, docs) and are themselves gated; folding them in
20
+ * would make unrelated documentation work invalidate the receipt.
21
+ */
22
+ import { createHash } from 'node:crypto';
23
+ import { existsSync, readFileSync, readdirSync } from 'node:fs';
24
+ import { join } from 'node:path';
25
+
26
+ /** Files/dirs whose content the receipt covers. Order is normalised below. */
27
+ const SRC_DIR = 'src';
28
+ const FILES = [
29
+ 'test/browser/fixture.js',
30
+ 'test/browser/probe.js',
31
+ 'test/browser/probe-detail.js',
32
+ 'test/browser/probe-detail2.js',
33
+ 'test/browser/probe-detail3.js',
34
+ 'test/browser/probe-en.js',
35
+ 'scripts/browser-check.mjs',
36
+ 'scripts/browser-harness.mjs',
37
+ 'scripts/probe-digest.mjs'
38
+ ];
39
+
40
+ /** The list the receipt covers, for error messages. */
41
+ export const probeInputs = () => {
42
+ const src = join(SRC_DIR);
43
+ const srcFiles = readdirSync(src).filter((f) => f.endsWith('.js')).sort().map((f) => join(SRC_DIR, f));
44
+ return [...srcFiles, ...FILES];
45
+ };
46
+
47
+ /**
48
+ * sha256 over every covered file. A missing file throws: a receipt that cannot describe
49
+ * the tree must not silently describe a smaller one.
50
+ */
51
+ export const digestProbeInputs = (root) => {
52
+ const hash = createHash('sha256');
53
+ for (const rel of probeInputs()) {
54
+ const abs = join(root, rel);
55
+ if (!existsSync(abs)) throw new Error('probe-digest: missing input ' + rel);
56
+ hash.update(rel + '\u0000');
57
+ hash.update(readFileSync(abs));
58
+ hash.update('\u0000');
59
+ }
60
+ return hash.digest('hex');
61
+ };
@@ -17,7 +17,13 @@
17
17
  * 2. `src/` moved on after the probe ran, and nothing anywhere said so.
18
18
  *
19
19
  * `browser-check.mjs` now writes `test/browser/probe-receipt.json` on PASS, carrying a
20
- * digest of `src/*.js`. This script recomputes the digest and fails on any mismatch.
20
+ * digest of everything the probe actually verified — `src/`, the fixture, every probe
21
+ * file and the two driver scripts (see `probe-digest.mjs`). This script recomputes that
22
+ * digest and fails on any mismatch.
23
+ *
24
+ * The digest deliberately covers the ASSERTIONS too. A receipt over `src/` alone stayed
25
+ * green while someone deleted a hundred assertions — it recorded that "a probe passed",
26
+ * not that "this probe passed".
21
27
  *
22
28
  * WHAT IT PROVES: the probe passed, on a tree whose src/ digest is this one.
23
29
  * WHAT IT DOES NOT PROVE: that the probe would still pass right now (only running it
@@ -28,26 +34,16 @@
28
34
  * node scripts/probe-receipt-check.mjs # fail on mismatch
29
35
  * node scripts/probe-receipt-check.mjs --explain # say what to run instead of failing
30
36
  */
31
- import { createHash } from 'node:crypto';
32
- import { existsSync, readFileSync, readdirSync } from 'node:fs';
37
+ import { existsSync, readFileSync } from 'node:fs';
33
38
  import { dirname, join } from 'node:path';
34
39
  import { fileURLToPath } from 'node:url';
40
+ import { digestProbeInputs } from './probe-digest.mjs';
35
41
 
36
42
  const ROOT = dirname(dirname(fileURLToPath(import.meta.url)));
37
43
  const RECEIPT = join(ROOT, 'test', 'browser', 'probe-receipt.json');
38
44
  const explain = process.argv.includes('--explain');
39
45
 
40
- const digestOfSrc = () => {
41
- const hash = createHash('sha256');
42
- const dir = join(ROOT, 'src');
43
- for (const f of readdirSync(dir).sort()) {
44
- if (!f.endsWith('.js')) continue;
45
- hash.update(f + '\u0000');
46
- hash.update(readFileSync(join(dir, f)));
47
- hash.update('\u0000');
48
- }
49
- return hash.digest('hex');
50
- };
46
+ const digestOfSrc = () => digestProbeInputs(ROOT);
51
47
 
52
48
  if (!existsSync(RECEIPT)) {
53
49
  console.error('probe-receipt: MISSING — the browser probe has never run against this tree.');
@@ -65,7 +61,8 @@ try {
65
61
 
66
62
  const actual = digestOfSrc();
67
63
  if (receipt.src_digest !== actual) {
68
- console.error('probe-receipt: STALE — src/ changed after the probe last passed.');
64
+ console.error('probe-receipt: STALE — the probe inputs changed after the probe last passed.');
65
+ console.error(' (src/, the fixture, the probe files, or the driver scripts)');
69
66
  console.error(' receipt: ' + String(receipt.src_digest).slice(0, 16) + '… (' + String(receipt.ran_at) + ')');
70
67
  console.error(' actual: ' + actual.slice(0, 16) + '…');
71
68
  console.error(' run: node scripts/browser-check.mjs');
package/src/00-locale.js CHANGED
@@ -99,6 +99,7 @@
99
99
  "detail.items": "项",
100
100
  "detail.request": "请求配置",
101
101
  "detail.systemPrompt": "系统提示",
102
+ "detail.showAll": "显示全文",
102
103
  "detail.systemOutside": "来自窗口外的系统事件 e{seq}",
103
104
  "detail.systemNone": "(当前窗口内没有系统提示)",
104
105
  "detail.toolsCatalog": "工具目录",
@@ -286,6 +287,7 @@
286
287
  "detail.items": "items",
287
288
  "detail.request": "Request config",
288
289
  "detail.systemPrompt": "System prompt",
290
+ "detail.showAll": "Show all",
289
291
  "detail.systemOutside": "from system event e{seq} outside the window",
290
292
  "detail.systemNone": "(no system prompt in this window)",
291
293
  "detail.toolsCatalog": "Tool catalog",
package/src/10-styles.js CHANGED
@@ -180,6 +180,11 @@
180
180
  // printed the source, so users read "**0.9.13**" and "# heading" literally.
181
181
  // Blocks below restore the visual hierarchy the transcript actually has.
182
182
  ".dstv_dMarkdown{white-space:normal}",
183
+ // The detail panel folds very long bodies (DETAIL_TEXT_MAX); this is the one
184
+ // control that brings the rest back, so it must be a real, focusable button.
185
+ ".dstv_foldBtn{margin-top:8px;padding:4px 10px;font:inherit;font-size:11px;color:var(--dstv-accent);background:transparent;border:1px solid var(--dstv-border);border-radius:6px;cursor:pointer}",
186
+ ".dstv_foldBtn:hover{background:var(--dstv-hover)}",
187
+ ".dstv_foldBtn:focus-visible{outline:2px solid var(--dstv-accent);outline-offset:2px}",
183
188
  // A caption + body card reads as a document section; without it the label and
184
189
  // the prose collapse into one paragraph line.
185
190
  ".dstv_dSectionBody{gap:4px;padding:8px 10px;border:1px solid var(--dsw-alias-border-l2);border-radius:9px;background:var(--dsw-alias-bg-layer-2)}",
package/src/40-view.js CHANGED
@@ -110,6 +110,40 @@
110
110
  return p.text;
111
111
  });
112
112
  }
113
+ /**
114
+ * How much of a message the detail panel renders before offering "show all".
115
+ *
116
+ * The panel deliberately does NOT truncate the DATA — copying, exporting and the
117
+ * tooltip all still use the whole string. What it truncates is the DOM: a 1 MB
118
+ * message was parsed as markdown and poured into a single text node, and opening
119
+ * its detail panel measured 488 ms (1,000,042 characters of `textContent`).
120
+ * 50,000 keeps the common case (long log dump, stack trace) intact and costs
121
+ * ~30 ms; the button makes the rest one click away, so nothing is lost.
122
+ */
123
+ const DETAIL_TEXT_MAX = 50000;
124
+
125
+ /** Long text rendered as markdown, with an explicit "show all" affordance. */
126
+ function FoldedMarkdown({ text, expandLabel, suffix }) {
127
+ const expandedState = (0, react.useState)(false);
128
+ const expanded = expandedState[0];
129
+ const setExpanded = expandedState[1];
130
+ const value = typeof text === "string" ? text : "";
131
+ const long = value.length > DETAIL_TEXT_MAX;
132
+ if (!long || expanded) return jsx(MarkdownText, { text: value }, long ? "mdAll" : "md");
133
+ return jsxs("div", { children: [
134
+ jsx(MarkdownText, { text: value.slice(0, DETAIL_TEXT_MAX) }, "mdPart"),
135
+ jsx("button", {
136
+ type: "button",
137
+ className: "dstv_foldBtn",
138
+ // The count is in the label so a screen-reader user knows how much is hidden
139
+ // before deciding to render it.
140
+ "aria-expanded": "false",
141
+ onClick: () => setExpanded(true),
142
+ children: `${expandLabel} (${value.length - DETAIL_TEXT_MAX} ${suffix})`
143
+ }, "foldBtn")
144
+ ] }, "foldWrap");
145
+ }
146
+
113
147
  function MarkdownText({ text }) {
114
148
  const blocks = (0, react.useMemo)(() => mdBlocks(text), [text]);
115
149
  const nodes = blocks.map((b, i) => {
@@ -2018,7 +2052,7 @@
2018
2052
  // Markdown too: users paste code blocks and lists just as often.
2019
2053
  return jsxs("div", { className: "dstv_dBody", children: jsxs("div", { className: "dstv_dSection dstv_dSectionBody", children: [
2020
2054
  jsx("span", { className: "dstv_dLabel", children: s.who }, "dLbl"),
2021
- jsx("div", { className: "dstv_dText dstv_dMarkdown", children: s.text !== "" ? jsx(MarkdownText, { text: s.text }, "uMd") : "…" }, "dTxt")
2055
+ jsx("div", { className: "dstv_dText dstv_dMarkdown", children: s.text !== "" ? jsx(FoldedMarkdown, { text: s.text, expandLabel: t("detail.showAll"), suffix: t("detail.chars") }, "uMd") : "…" }, "dTxt")
2022
2056
  ] }) });
2023
2057
  }
2024
2058
  if (s.kind === "step") {
@@ -2031,9 +2065,9 @@
2031
2065
  jsx("span", { className: "dstv_dLabel", children: t("node.assistant") }, "aLbl"),
2032
2066
  cell.thinking !== "" ? jsxs("details", { className: "dstv_det", open: false, children: [
2033
2067
  jsx("summary", { children: [`💭 ${t("chip.thinking")}`, jsx("span", { className: "sub", children: String(cell.thinking.length) }, "aThLen")] }, "aThSum"),
2034
- jsx("div", { className: "inner", children: jsx("div", { className: "dstv_dText sec", children: jsx(MarkdownText, { text: cell.thinking }, "aThMd") }, "aThText") }, "aThInner")
2068
+ jsx("div", { className: "inner", children: jsx("div", { className: "dstv_dText sec", children: jsx(FoldedMarkdown, { text: cell.thinking, expandLabel: t("detail.showAll"), suffix: t("detail.chars") }, "aThMd") }, "aThText") }, "aThInner")
2035
2069
  ] }, `dth${cell.id}`) : null,
2036
- cell.text !== "" ? jsx("div", { className: "dstv_dText dstv_dMarkdown", children: jsx(MarkdownText, { text: cell.text }, "aMd") }, "aText") : null
2070
+ cell.text !== "" ? jsx("div", { className: "dstv_dText dstv_dMarkdown", children: jsx(FoldedMarkdown, { text: cell.text, expandLabel: t("detail.showAll"), suffix: t("detail.chars") }, "aMd") }, "aText") : null
2037
2071
  ] }, `da${cell.id}`);
2038
2072
  }
2039
2073
  if (cell.kind === "tool") {