Commit Graph
3 Commits
Author SHA1 Message Date
OCILY fe06211775 fix(mermaid): isolate diagram layout in a sandboxed iframe
Mermaid measures every label with SVGElement.getBBox() against a node
appended to document.body, so each measurement flushes the whole host
document's layout. Measured in the live DSH window (15,418 DOM nodes):
59-75 ms per measurement, versus 1 ms in an empty iframe document. One
diagram therefore took 1.5-7.3 s, and a 31-diagram markdown document kept
the renderer main thread blocked for >20 s - long enough for the desktop
shell's surface watchdog to kill the renderer, with tab restoration
turning it into a crash loop. CSS containment on the app root does not
help (59-62 ms); only an independent layout tree does.

Render diagrams inside a hidden sandboxed iframe instead: a self-contained
blob: document (mermaid UMD bundle + a small postMessage protocol, both
inlined by scripts/build-mermaid-frame-asset.mjs) renders each diagram;
the parent only sends/receives and sanitizes the SVG. Diagrams now take
30-104 ms each and 31 diagrams complete in ~5 s in the background, while
the client mermaid chunk shrinks from 7.04 MB to 3.69 MB (minified UMD
replaces the unminified inline bundle).

Also add a shared render queue: visible/near-viewport diagrams first, the
rest filled in on requestIdleCallback with 16 ms main-thread yields between
renders, so every diagram is still rendered (none degrades to a code
block). Fence-line-sized placeholder skeletons reserve height while a
diagram waits. No host-half route changes are needed.
2026-10-28 20:20:49 +08:00
Menghuan1918 da0d294948 fix(release): 版本常量与 Windows 路径两处 CI 红
1. src/client/service.ts 的 SIDEBAR_SERVICE_VERSION 仍是 0.26.0,而
   tests/service.spec.ts 钉住它与 package.json 同版本(设计如此,是我漏了)。
2. 新的定时器清单 spec 用 `path.slice(root.length)` 取包内相对路径,在 Windows
   上留下前导反斜杠(\\JobsDrawer.tsx)导致两边永不相等——改用
   `relative() + split(sep).join('/')`,与 AGENTS §6「按平台推导路径要用同方言的
   node:path」同规。
2026-10-16 00:15:45 +08:00
Menghuan1918 ebfb207f08 test(perf): 稳态门禁(跨模块计时器/布局/请求 + 客户端定时器清单)
单模块用例各盯自己的 hook;这条只问跨模块的问题:把真实 Sidebar 壳挂起来、
什么都不给看时,它手里还握着多少会自己跑起来的东西。

- 非 blank 会话只允许存在**一条** 500ms 表(共享的宿主面板展开态),且不得存在 5s
  表(每 tab 轮询已收敛为按会话 + 可见性);收起工作台时壳自己不得发 session.cwd;
  隐藏页面时那条 500ms 表也必须消失,恢复即可重挂。
- 兜底入口在非 blank 会话渲染 null:宿主角落控件在场(measure() 能走到让位走查)
  时命中测试必须为 0——before 侧真机实测 1620 次,after 侧 0。
- 末节是**客户端 setInterval 站点清单**:8 个站点逐一登记「它什么时候停」,新增未
  登记的周期任务即红,登记了门控词却把门控删掉也红(绊线)。
- perf lane 新增 steady-state 指标与两条硬断言(兜底入口不渲染即不得命中测试、
  session.cwd 必须按会话而非按访问过的页签计数)。真机 A/B:500ms 表 3→1、
  5s 表 5→0、空闲窗 session.cwd 15→0、命中测试 1620→0、rect 5190→30。
2026-10-15 23:05:43 +08:00